How can I Stop/start/Pause a @JmsListener (the clean way)

Here is the solution I’ve found @RestController @RequestMapping(“/jms”) public class JmsController { @Autowired ApplicationContext context; @RequestMapping(value=”/halt”, method= RequestMethod.GET) public @ResponseBody String haltJmsListener() { JmsListenerEndpointRegistry customRegistry = context.getBean(“jmsRegistry”, JmsListenerEndpointRegistry.class); customRegistry.stop(); return “Jms Listener Stopped”; } @RequestMapping(value=”/restart”, method=RequestMethod.GET) public @ResponseBody String reStartJmsListener() { JmsListenerEndpointRegistry customRegistry = context.getBean(“jmsRegistry”, JmsListenerEndpointRegistry.class); customRegistry.start(); return “Jms Listener restarted”; } @RequestMapping(value=”/stopApp”, method=RequestMethod.GET) public … Read more

Adding Dynamic Number of Listeners(Spring JMS)

You can’t do it with annotated @JmsListeners but you can register each listener programmatically by extending JmsListenerConfigurer as described in the reference documentation. EDIT Since you are injecting the property as an array… @Value(“${InTopics}”) private String[] inTopics; Spring will split up the list an create an array based on the number of queues in the … Read more