简体   繁体   English

JMS自动重新连接到TOPIC

[英]JMS automatically reconnecting to TOPIC

I have two apps one app is publishing to a topic and another app is reading from that topic. 我有两个应用程序,一个应用程序正在发布到一个主题,另一个应用程序正在从该主题读取。 We had a scenario where a queuemanager went down and then was available again. 我们有一个场景,其中队列管理器发生故障,然后又可用。 The publisher (without a restart) carries on working fine after the queuemanager restarts, but the topic consumer does not recieve the new messages from the publisher until it is restarted. 队列管理器重新启动后,发布者(无需重新启动)可以正常工作,但是主题使用者在重新启动之前不会从发布者那里收到新消息。 Is there some configuration that can be setup on the topic consumer to refresh its connection somehow? 是否可以在主题使用者上设置一些配置以某种方式刷新其连接? We are using java / spring / spring integration over IBM MQ. 我们正在通过IBM MQ使用java / spring / spring集成。 The following is the configuration of our consumer. 以下是我们消费者的配置。

<bean id="jmsAlertsServiceMessageListener" class="org.springframework.jms.listener.DefaultMessageListenerContainer">
    <property name="connectionFactory" ref="alertConnectionFactory"/>
    <property name="destination" ref="alertsServiceTopic"/>
    <property name="autoStartup" value="false"/>
    <property name="clientId" value="${ps.Alert.clientId}"/>
    <property name="taskExecutor" ref="jmsTaskExecutor"/>
    <property name="subscriptionDurable" value="true"/>
    <property name="pubSubDomain" value="true"/>
    <property name="messageSelector" value="AlertState = 'RESOLVED'"/>
    <property name="messageListener" ref="alertsMessageListener"/>
    <property name="durableSubscriptionName" value="replay"/>
    <property name="recoveryInterval" value="30000"/>
</bean>

<bean id="alertConnectionFactory" class="com.ibm.mq.jms.MQConnectionFactory"  >
    <property name="transportType" value="1" />   
    <property name="queueManager" value="${alert.mq.qm}" />
    <property name="hostName" value="${alert.mq.host}" />
    <property name="port" value="${alert.mq.port}" />
    <property name="channel" value="${alert.mq.channel}" />     
    <property name="SSLCipherSuite" value="SSL_RSA_WITH_RC4_128_SHA" />        
    <property name="brokerPubQueue" value="${alert.mq.topic_connection_factory_broker_pub_queue}"/>
    <property name="brokerQueueManager" value="${alert.mq.topic_connection_factory_broker_queue_manager}"/>
    <property name="providerVersion" value="${alert.mq.topic_connection_factory_provider_version}"/>
    <property name="brokerVersion" value="1"/>       
    <property name="messageSelection" value="1"/>     
</bean>

<bean id="alertsServiceTopic" class="com.ibm.mq.jms.MQTopic">
    <constructor-arg value="${alert.mq.topic}" />
    <property name="brokerDurSubQueue" value="${alert.mq.queue}"/>        
    <property name="brokerVersion" value="1"/>          
</bean>

<bean id="alertsMessageListener" class="org.springframework.integration.jms.ChannelPublishingJmsMessageListener">
    <property name="requestChannel" ref="alertsJmsInputChannel"/>
</bean>

<bean id="jmsTaskExecutor" class="org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor">
    <property name="corePoolSize" value="1"/>
    <property name="maxPoolSize" value="1"/>
    <property name="waitForTasksToCompleteOnShutdown" value="true"/>
    <property name="daemon" value="false"/>
    <property name="threadNamePrefix" value="jmsInbound-"/>
    <property name="queueCapacity" value="3"/>
    <!-- Discard any task that gets rejected. -->
    <property name="rejectedExecutionHandler">
        <bean class="java.util.concurrent.ThreadPoolExecutor$DiscardPolicy"/>
    </property>
</bean>

The DefaultMessageListenerContainer will automatically reconnect according to the recoveryInterval . DefaultMessageListenerContainer将根据recoveryInterval自动重新连接。

Turn on DEBUG (or even TRACE) logging to figure out what's happening. 打开DEBUG(甚至TRACE)日志记录以了解发生了什么。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM