DefaultMessageListenerContainer 类的文档中提到,不建议将 CachingConnectionFactory 与动态缩放一起使用 . 在搜索时,我遇到了以下链接:

Why DefaultMessageListenerContainer should not use CachingConnectionFactory?

这里发现了Gary Russell的评论

问题在于在容器中使用变量并发时缓存消费者;我们最终可能会将现场消费者“卡在”缓存中“ .

我们一起使用 DefaultMessageListenerContainerCachingConnectionFactory 所以这肯定是上面链接的一个问题 .

我们的应用程序遇到以下行为时遇到问题:

  • TCP ZeroWindow网络拥塞

  • 从应用程序服务器到MQ的TCP RESET

  • 数据库连接在问题期间增长,而不同的事务停止

  • 某些队列中的消息已 Build

我们有以下代码配置:

  • 在ibmmq-context.xml文件中:
<!-- WebSphere MQ Connection Factory -->
<bean id="appMqConnectionFactory" class="com.ibm.mq.jms.MQConnectionFactory">
   <property name="hostName">
       <value>${ibmmq.ip}</value>
   </property>
   <property name="port">
       <value>${ibmmq.port}</value>
   </property>
   <property name="queueManager">
       <value>${ibmmq.queuemanager}</value>
   </property>
   <property name="channel"> 
<value>${ibmmq.channel}</value> 
</property>
   <property name="clientReconnectOptions"> 
<util:constant static-field="com.ibm.msg.client.wmq.WMQConstants.WMQ_CLIENT_RECONNECT"/> 
</property>
<property name="transportType" ref="appTransport"/>
</bean>

<!-- A cached connection  -->
    <bean id="appCachedConnectionFactory" class="org.springframework.jms.connection.CachingConnectionFactory">
        <property name="targetConnectionFactory" ref="appMqConnectionFactory"/>
        <property name="sessionCacheSize" value="${jms.session.cachesize}"/>
    </bean>

    <!--  Use native MQ classes. -->
<bean id="appTransport" class="org.springframework.beans.factory.config.FieldRetrievingFactoryBean">
<property name="staticField">
<value>com.ibm.mq.jms.JMSC.MQJMS_TP_CLIENT_MQ_TCPIP</value>
</property>
</bean>
  • 在jms-context文件中:
<bean id="bankListener"  class="org.springframework.jms.listener.DefaultMessageListenerContainer">
  <property name="connectionFactory" ref="cachedConnectionFactory" />
  <property name="destination" ref="transactionResponseDestination" />
  <property name="messageListener" ref="thirdpartyService" />
  <property name="autoStartup" value="false"/>
  <property name="taskExecutor" ref="listenerExecutor"/>
  <property name="concurrency" value="20-30"/>
</bean>

有6个像bankListener这样的监听器,每个监听器都有并发值,从10到40不等

<bean id="listenerExecutor" class="org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor">
  <property name="maxPoolSize" value="140"/>
  <property name="corePoolSize" value="100"/>
  <property name="queueCapacity" value="30"/>
  <property name="threadNamePrefix" value="jms-listener-task-"/>
  <property name="threadGroupName" value="jms-listener-tasks"/>
</bean>

jms-context.xml 文件使用 ibmmq-context.xml 文件 .

  • 需要注意的是,我们使用了IBM MQ 7.1,Spring 4.2.8,spring-integration-core作为4.3.1.RELEASE和JBoss EAP 6.4.10

我们计划通过以下方式解决此问题:

<bean id="bankListener" class="org.springframework.jms.listener.DefaultMessageListenerContainer">
  <property name="connectionFactory" ref="appMqConnectionFactory" />
  <property name="destination" ref="transactionResponseDestination" />
  <property name="messageListener" ref="thirdpartyService" />
  <property name="autoStartup" value="false"/>
  <property name="taskExecutor" ref="listenerExecutor"/>
  <property name="concurrency" value="20-30"/>
</bean>

我的请求:

  • 请查看配置并告诉我还有什么需要更改的 .

  • 你能否用我们当前的配置 CachingConnectionFactoryDefaultMessageListenerContainer 解释我们的应用行为(4点以上 - a到d)

在此先感谢您的帮助 .