无法停止MQueue侦听器 [英] Not able to Stop MQueue listener

查看:111
本文介绍了无法停止MQueue侦听器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的MQueue具有以下配置:

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>

当我尝试停止接收JMS消息时,我写了以下代码

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:

  • 当我stop()我的侦听器时,isRunning()返回False,但是我仍然通过MQueue获取消息... onMessage被触发.
  • jmsManagement是类Lifecycle的实例.即使我将其更改为DefaultMessageListenerContainer,也是如此.
  • 即使autoStartup设置为false,我也要在呼叫start()之前收到消息.
  • jmsManagement.shutdown();并没有阻止监听器被触发.
  • When I stop() my listener, the isRunning() return False, but I still get messages through the MQueue... the onMessage gets triggered.
  • jmsManagement is an instance of the class Lifecycle. Even when I changed it to DefaultMessageListenerContainer, same thing.
  • I'm receiving messages before calling start(), even when autoStartup is set to false.
  • jmsManagement.shutdown(); didn't stop the listener from being triggered.

有人知道如何停止此MQ侦听器吗? 有什么我想念的吗?

Does anyone have an idea about how to stop this MQ listener ? Is there something I'm missing ?

推荐答案

我实际上必须将autoStartup设置为 true .

I actually had to set autoStartup to true.

由于无法使用jms:listener-container进行此操作,因此实例化了DefaultMessageListenerContainer bean,并将autoStartup属性设置为 false .

Since I can't do that using jms:listener-container, I instanciated a DefaultMessageListenerContainer bean and set the autoStartup property to false.

这是对我有用的代码:

<bean class="org.springframework.jms.listener.DefaultMessageListenerContainer"  id="pitagorCPYListener">
    <property name="autoStartup" value="false" />
    <property name="connectionFactory" ref="cachedConnectionFactory" />
    <property name="destination" ref="defaultDestination" />
    <property name="messageListener" ref="listenerPitagorCPY" />
</bean>

 <bean id="defaultDestination" class="com.ibm.mq.jms.MQQueue">
    <constructor-arg value="#{mqConnectionFactory.destination}"/>
  </bean>

这篇关于无法停止MQueue侦听器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆