【问题标题】:Spring CachingConnectionFactory not reaping when idleSpring CachingConnectionFactory 在空闲时没有收获
【发布时间】:2015-05-24 08:16:48
【问题描述】:

我在下面的配置中使用 spring CachingConnectionFactory 来缓存 MQ 会话。我可以看到缓存按预期工作:

  • 它打开单个 MQ 连接
  • 根据需要创建新会话并重复使用它们

我的应用程序的消息流量高峰期很短。因此,当出现峰值时,会话大小会膨胀并在峰值后很长时间保持在那里。我正在寻找一种在特定时间不活动后获得这些空闲会话的方法。有没有办法做到这一点?

<jee:jndi-lookup id="mqQueueConnectionFactory" jndi-name="java:comp/env/jms/MyJMSQueueConnectionFactory" />

<bean id="userConnectionFactory" class="org.springframework.jms.connection.UserCredentialsConnectionFactoryAdapter">
    <property name="targetConnectionFactory" ref="mqQueueConnectionFactory"></property>
</bean>
<bean id="queueConnectionFactory" class="org.springframework.jms.connection.CachingConnectionFactory">
    <property name="targetConnectionFactory" ref="userConnectionFactory"></property>
    <property name="reconnectOnException" value="${ssa.mq.cachesession}"></property>
    <property name="cacheProducers" value="${ssa.mq.cacheproducer}"></property>
    <property name="sessionCacheSize" value="${ssa.mq.producer.sessionsize}"></property>
    <property name="cacheConsumers" value="${ssa.mq.cacheconsumers}"></property>
</bean>

【问题讨论】:

    标签: jms connection-pooling spring-integration ibm-mq spring-jms


    【解决方案1】:

    你可以减少sessionCacheSize;超过缓存大小时关闭的任何会话将在下次使用时物理关闭。

    【讨论】:

    • 你能详细说明一下吗? - “超过缓存大小时关闭的任何会话将在下次使用时物理关闭”。你是说会话大小在峰值负载时会增长到任意数字,然后在负载较低时回落到 sessionCacheSize?
    • 正确 - 请参阅 session creationsession closing (logical Vs. physical)TRACE 级别日志记录将为您提供全貌。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2014-10-12
    • 1970-01-01
    • 2013-11-27
    • 2019-06-10
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多