title: ActiveMQ delayed delivery of messages in Spring Boot
body: <p>My question is really similar to <a href="https://stackoverflow.com/questions/25121094/spring-jmsactivemq-delayed-delivery-of-messages">Spring JMS(ActiveMQ) delayed delivery of messages</a> but more correlated to the spring-boot auto configurer</p>
  
  <p>I'm trying to use the <code>jmsTemplate.setDeliveryDelay</code> method, but it throws a <code>java.lang.IllegalStateException: setDeliveryDelay requires JMS 2.0</code></p>
  
  <p>I tried to find the right property from <a href="http://docs.spring.io/spring-boot/docs/current/reference/html/common-application-properties.html" rel="nofollow noreferrer">http://docs.spring.io/spring-boot/docs/current/reference/html/common-application-properties.html</a> but couldn't find the broker schedulerSupport option.</p>
  
  <p>Currently, my application.properties is empty, and my JmsListenerContainerFactory is defined as follows</p>
  
  <pre><code>@Bean
  public JmsListenerContainerFactory&lt;?&gt; myFactory(ConnectionFactory connectionFactory,
                                                  DefaultJmsListenerContainerFactoryConfigurer configurer) {
      DefaultJmsListenerContainerFactory factory = new DefaultJmsListenerContainerFactory();
  
      configurer.configure(factory, connectionFactory);
      return factory;
  }
  </code></pre>
  
  <p>And my pom only contains</p>
  
  <pre><code>    &lt;dependency&gt;
          &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
          &lt;artifactId&gt;spring-boot-starter-activemq&lt;/artifactId&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
          &lt;artifactId&gt;spring-boot-starter-web&lt;/artifactId&gt;
      &lt;/dependency&gt;
  </code></pre>
  
  <p>With the spring-boot-starter-parent in 1.4.1.RELEASE</p>
  
  <p>The question is: Is it possible to set the schedulerSupport to true using SpringBoot configurations?</p>
  
  <p>In case it's needed, here are my Sender</p>
  
  <pre><code>public void send(String message) {
      System.out.println("Im sending this message " + message);
      jmsTemplate.setDeliveryDelay(5000);
      jmsTemplate.convertAndSend(Beans.QUEUE_NAME, message);
  }
  </code></pre>
  
  <p>and Receiver</p>
  
  <pre><code>@JmsListener(destination = Beans.QUEUE_NAME, containerFactory = "myFactory")
  public void receiveMessage(String message) {
      System.out.println("Received this message &lt;" + message + "&gt;");
  }
  </code></pre>
  
  <p>thanks in advance</p>
  
  <hr>
  
  <p>Update: I tried put it in the message properties, like the documentation <a href="http://activemq.apache.org/delay-and-schedule-message-delivery.html" rel="nofollow noreferrer">http://activemq.apache.org/delay-and-schedule-message-delivery.html</a> , but it doesn't work</p>
  
  <pre><code>@Bean
  public MessageConverter messageConverter() {
      MessageConverter converter = new MessageConverter(){
          @Override
          public Message toMessage(Object object, Session session) throws JMSException, MessageConversionException {
              if (!(object instanceof MyPojo)) {
                  throw new MessageConversionException("not agreed Pojo!");
              }
              MyPojo pojo = (MyPojo) object;
  
              Message message = session.createTextMessage(pojo.getMessage());
              message.setLongProperty(ScheduledMessage.AMQ_SCHEDULED_DELAY, pojo.getScheduledWait());
              return message;
          }
          @Override
          public Object fromMessage(Message message) throws JMSException, MessageConversionException {
              return message;
          }
      };
      return converter;
  }
  </code></pre>