2

I am using Spring 4.1+ with a decorated @JmsListener method to process incoming messages. Is there a way to get a reference to the underlying DefaultMessageListenerContainer so that I can stop/start the related listeners in the code?

My @Configuration bean only creates a factory:

@Bean
public DefaultJmsListenerContainerFactory myContainerFactory() throws JMSException {
    DefaultJmsListenerContainerFactory factory = new DefaultJmsListenerContainerFactory();
    factory.setConnectionFactory(connectionFactory());
    factory.setDestinationResolver(destinationResolver());
    factory.setConcurrency(env.getProperty("RE_MQ_SET_CONCURRENCY"));
    return factory;
}

I understand I can use a DefaultMessageListener explicitly and then use setMessageListener() to assign the method, but I liked the elegance of the @JmsListener annotation.

Cœur
  • 37,241
  • 25
  • 195
  • 267
TemarV
  • 317
  • 1
  • 4
  • 12

0 Answers0