Allan Vital Allan Vital - 10 months ago 186
Java Question

ActiveMQ delayed delivery of messages in Spring Boot

My question is really similar to Spring JMS(ActiveMQ) delayed delivery of messages but more correlated to the spring-boot auto configurer

I'm trying to use the

method, but it throws a
java.lang.IllegalStateException: setDeliveryDelay requires JMS 2.0

I tried to find the right property from but couldn't find the broker schedulerSupport option.

Currently, my is empty, and my JmsListenerContainerFactory is defined as follows

public JmsListenerContainerFactory<?> myFactory(ConnectionFactory connectionFactory,
DefaultJmsListenerContainerFactoryConfigurer configurer) {
DefaultJmsListenerContainerFactory factory = new DefaultJmsListenerContainerFactory();

configurer.configure(factory, connectionFactory);
return factory;

And my pom only contains


With the spring-boot-starter-parent in 1.4.1.RELEASE

The question is: Is it possible to set the schedulerSupport to true using SpringBoot configurations?

In case it's needed, here are my Sender

public void send(String message) {
System.out.println("Im sending this message " + message);
jmsTemplate.convertAndSend(Beans.QUEUE_NAME, message);

and Receiver

@JmsListener(destination = Beans.QUEUE_NAME, containerFactory = "myFactory")
public void receiveMessage(String message) {
System.out.println("Received this message <" + message + ">");

thanks in advance

Update: I tried put it in the message properties, like the documentation , but it doesn't work

public MessageConverter messageConverter() {
MessageConverter converter = new MessageConverter(){
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;
public Object fromMessage(Message message) throws JMSException, MessageConversionException {
return message;
return converter;

Answer Source

I don't know if it's cheating, but what solved the problem for me was change the starter from activemq to artemis (

Apparently, spring configures, by default, the Artemis to the JMS 2.0 interface. This way you have access to setDeliveryDelay method.