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