title: Create durable topic and subscriber spring boot jms with ActiveMQ
body: <p>I need to create a topic and a durable subscriber for ActiveMQ, my problem is that I don't know where to specify that. I am able to create the topic and consume the messages, but when I turn off the subscriber then keep sending messages and turn on the subscriber again, it won't read them.</p>
  
  <p>This is what I have so far:</p>
  
  <p>Sending the message : </p>
  
  <pre><code>    JmsTemplate jmsTemplate = context.getBean(JmsTemplate.class);
      jmsTemplate.setPubSubDomain(true);
      jmsTemplate.setDeliveryMode(DeliveryMode.PERSISTENT);
      jmsTemplate.setDeliveryPersistent(true);
      jmsTemplate.convertAndSend("venta.topic",venta);
  </code></pre>
  
  <p>Receiving the message : </p>
  
  <pre><code>@JmsListener(destination = "venta.topic",id = "comercial",subscription = "venta.topic")
  public void receiveMessage(Venta venta) {
      logger.log(Level.INFO, "RECEIVED : {0}",venta);      
      repository.save(venta);
  }
  </code></pre>
  
  <p>I have read <a href="http://docs.oracle.com/javaee/1.3/jms/tutorial/1_3_1-fcs/doc/advanced.html#1024758" rel="noreferrer">this article</a> and I understand that I need to create the durable subscriber. </p>
  
  <p>I've also read the <a href="https://docs.spring.io/spring/docs/current/spring-framework-reference/html/jms.html" rel="noreferrer">spring docs</a></p>
  
  <p>And I think it has something to do with the <code>DefaultJmsListenerContainerFactory</code> (which I didn't implement, I am using the default configuration), the docs shows: </p>
  
  <pre><code>@Bean
  public DefaultJmsListenerContainerFactory jmsListenerContainerFactory() {
      DefaultJmsListenerContainerFactory factory =
              new DefaultJmsListenerContainerFactory();
      factory.setConnectionFactory(connectionFactory());
      factory.setDestinationResolver(destinationResolver());
      factory.setConcurrency("3-10");
      return factory;
  }
  </code></pre>
  
  <p>But I can't seem to find where to create the durable session. Both my producer and my subscriber are connected to a standalone activemq binary.</p>
  
  <p>I hope you can help me , thanks in advance.</p>