복붙노트

[SPRING] MQueue 리스너를 중지 할 수 없습니다.

SPRING

MQueue 리스너를 중지 할 수 없습니다.

내 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 메시지 수신을 중지하려고하면 다음 코드를 작성합니다.

jmsManagement = myProject.instance.getContext().getBean('myListenerId',Lifecycle.class);
jmsManagement.stop();

추신 :

누구든지이 MQ 수신기를 중지하는 방법에 대한 아이디어가 있습니까? 내가 누락 된 것이 있습니까?

해결법

  1. ==============================

    1.실제로 autoStartup을 true로 설정해야했습니다.

    실제로 autoStartup을 true로 설정해야했습니다.

    jms : listener-container를 사용하여이를 수행 할 수 없기 때문에 DefaultMessageListenerContainer Bean을 인스턴스화하고 autoStartup 특성을 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>
    
  2. from https://stackoverflow.com/questions/43207792/not-able-to-stop-mqueue-listener by cc-by-sa and MIT license