天道酬勤,学无止境

message-listener

如何停止/启动/暂停@JmsListener(干净的方法)(How can I Stop/start/Pause a @JmsListener (the clean way))

问题 我在项目上使用Spring(boot),并使用以下命令访问JMS队列(ActiveMQ): @JmsListener(destination = "mydestinationQueue") public void processMessage(String content) { //do something } 它运行完美,但是我需要能够以编程方式停止/暂停/启动此Bean(REST调用或类似的东西) 当我停止或暂停该bean时,我想确保已完全处理了当前消息。 有什么想法吗? 谢谢 回答1 这是我找到的解决方案 @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)

2021-05-08 14:19:31    分类:技术分享    spring-boot   jms   spring-jms   message-listener

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

I am using Spring(boot) on my project and I access a JMS Queue (ActiveMQ) using : @JmsListener(destination = "mydestinationQueue") public void processMessage(String content) { //do something } And it works perfectly but I need to be able to stop/pause/start this bean programatically (a REST call or something like that) When I stop or pause this bean I want to be sure to have fully processed the current message. any idea about that ? thanks

2021-04-09 15:08:28    分类:问答    spring-boot   jms   spring-jms   message-listener