在applicationContext.xml中使用DefaultMessageListenerContainer时,ActiveMQ使用者不断增加

在applicationContext.xml中使用DefaultMessageListenerContainer时,ActiveMQ使用者不断增加,activemq,Activemq,我们定义了一个applicationContext.xml,其中包含ActiveMQ侦听器的容器。我们正在使用DefaultMessageListenerContainer,如下所示: <bean id="jmsFactory" class="org.apache.activemq.ActiveMQConnectionFactory"> <property name="brokerURL" value="${smqurl}"/> </bean> &l

我们定义了一个applicationContext.xml,其中包含ActiveMQ侦听器的容器。我们正在使用DefaultMessageListenerContainer,如下所示:

<bean id="jmsFactory" class="org.apache.activemq.ActiveMQConnectionFactory">
    <property name="brokerURL" value="${smqurl}"/>
</bean>

<bean id="documentListener" class="org.abc.jms.SMsgListener">
    <property name="appProperties" ref="ApplicationProperties"/>
</bean>

<bean id="cachingConnectionFactory"
    class="org.springframework.jms.connection.CachingConnectionFactory">
    <property name="targetConnectionFactory" ref="jmsFactory" />
    <property name="sessionCacheSize" value="1"/>
    <property name="cacheConsumers" value="false"/>
</bean>

<bean id="container"
    class="org.springframework.jms.listener.DefaultMessageListenerContainer">
    <property name="connectionFactory" ref="cachingConnectionFactory"/>
    <property name="messageListener" ref="documentListener"/>
    <property name="destinationName" value="SQueue" />
    <property name="concurrentConsumers" value="10" />
    <property name="maxConcurrentConsumers" value="20" />
</bean>

问题是消费者一直在增加,并没有被摧毁。最后,我们遇到了OutOfMemory异常

我们尝试查看文档和联机,但找不到任何明确的方法通过applicationContext.xml中的属性销毁/释放使用者

还有其他人遇到过类似的问题吗?你最终是如何解决这个问题的

谢谢。

我们用于JMS集成,它抽象了Spring的DMLC(DefaultMessageListenerContainer),根据我们的经验,它工作得非常好

尽管如此,我还是要这样来解决你的问题:

  • DMLC的默认缓存级别为
    cache\u CONSUMER
    ()。尝试调整此属性,并查看是否是DMLC导致泄漏
  • 首先使用VisialVM之类的工具进行堆分析(它随JDK一起提供,
    $JAVA_HOME/bin/jvisual.vm
    )。它可以让你看到内存中的对象是什么
  • 如果您正在评估Camel,这是RedHat的一位开发人员提供的,帮助我们解决了事务中的一些问题。如果您没有使用事务,这应该不是问题