spring-jms

How to disable Spring @JmsListener programmatically on startup

心不动则不痛 提交于 2019-11-30 21:08:42
I have a Spring application that has methods annotated with Spring's @JmsListener. The application is deployed on multiple nodes. On some specific nodes I need to disable the JMS listener so that it is not pulling messages off the queue. There appears to be a way to stop the listener after the application has started up. But this appears to leave open the brief window between startup and when the disable code runs where the application instance may consume messages. So instead is there a way to disable the listener during application startup. You need to customize the listener container

@JmsListener usage for publish-subscribe topic

时光毁灭记忆、已成空白 提交于 2019-11-30 03:51:19
I am trying to create example for publish-subscribe based on @JmsListener annotation: https://github.com/lkrnac/book-eiws-code-samples/tree/master/05-jms/0515-publish-subscribe Relevant code snippets: @Slf4j @SpringBootApplication @EnableScheduling public class JmsPublishSubscribeApplication { public static void main(String[] args) throws InterruptedException { SpringApplication.run(JmsPublishSubscribeApplication.class, args); } @Bean public ActiveMQTopic simpleTopic() { return new ActiveMQTopic("simpleTopic"); } } @Component public class SimpleMessageListener1 { @JmsListener(destination =

Closing Session when using Spring's CachingConnectionFactory

筅森魡賤 提交于 2019-11-29 19:03:42
问题 The java doc here related to Spring CachingConnectionFactory has comment : NOTE: This ConnectionFactory requires explicit closing of all Sessions obtained from its shared Connection. This is the usual recommendation for native JMS access code anyway. However, with this ConnectionFactory, its use is mandatory in order to actually allow for Session reuse. I am not clear how to handle this with the below given configuration in my application. <bean id="springApp" class="com.codereq.springcore

Not able to Stop MQueue listener

被刻印的时光 ゝ 提交于 2019-11-29 12:53:46
I have the following configuration for my MQueue: <jms:listener-container container-type="default" connection-factory="cachedConnectionFactory" acknowledge="auto"> <jms:listener id="myListenerId" destination="myDestination" ref="myListener" method="onMessage" /> </jms:listener-container> When I try to stop the reception of JMS messages, I write the following code jmsManagement = myProject.instance.getContext().getBean('myListenerId',Lifecycle.class); jmsManagement.stop(); PS : When I stop() my listener, the isRunning() return False, but I still get messages through the MQueue... the onMessage

Execution of JMS message listener failed, and no ErrorHandler has been set

五迷三道 提交于 2019-11-29 05:29:22
When I use Spring to listen to JMS messages, I receievd the above error. I am wondering how to add an Errorhandler into the JMS listener? There is a property on AbstractMessageListenerContainer : <bean id="listener" class="org.springframework.jms.listener.DefaultMessageListenerContainer"> <property name="errorHandler" ref="someHandler"/> <property name="destinationName" value="someQueue"/> <property name="connectionFactory" ref="connectionFactory"/> </bean> Where someHandler is a bean implementing ErrorHandler : @Service public class SomeHandler implements ErrorHandler { @Override public void

Start and Stop JMS Listener using Spring

こ雲淡風輕ζ 提交于 2019-11-29 04:20:53
So question is how to temporary stop and start a jms listener created using spring using the fallowing way : <amq:connectionFactory id="exampleJmsFactory" brokerURL="tcp://${jms.broker.url}" /> <jms:listener-container concurrency="1" connection-factory="exampleJmsFactory" destination-type="queue" message-converter="exampleMessageConverter"> <jms:listener destination="incoming.example.client.queue" ref="exampleProductsMessageConsumer" method="consume"/> </jms:listener-container> <bean id="exampleProductsMessageConsumer" class="com.unic.example.jms.receive.JmsExampleProductsMessageConsumer"

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

♀尐吖头ヾ 提交于 2019-11-29 02:04:37
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 Here is the solution I've found @RestController @RequestMapping("/jms") public class JmsController { @Autowired ApplicationContext context; @RequestMapping

Not able to Stop MQueue listener

拈花ヽ惹草 提交于 2019-11-28 06:33:15
问题 I have the following configuration for my MQueue: <jms:listener-container container-type="default" connection-factory="cachedConnectionFactory" acknowledge="auto"> <jms:listener id="myListenerId" destination="myDestination" ref="myListener" method="onMessage" /> </jms:listener-container> When I try to stop the reception of JMS messages, I write the following code jmsManagement = myProject.instance.getContext().getBean('myListenerId',Lifecycle.class); jmsManagement.stop(); PS : When I stop()

Start and Stop JMS Listener using Spring

自作多情 提交于 2019-11-27 18:25:22
问题 So question is how to temporary stop and start a jms listener created using spring using the fallowing way : <amq:connectionFactory id="exampleJmsFactory" brokerURL="tcp://${jms.broker.url}" /> <jms:listener-container concurrency="1" connection-factory="exampleJmsFactory" destination-type="queue" message-converter="exampleMessageConverter"> <jms:listener destination="incoming.example.client.queue" ref="exampleProductsMessageConsumer" method="consume"/> </jms:listener-container> <bean id=

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

天大地大妈咪最大 提交于 2019-11-27 16:38:40
问题 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 回答1: Here is the solution I've found @RestController