English 中文(简体)
Spring JmsTemplate和Apache ActiveMQ,为什么有这么多连接?
原标题:Spring JmsTemplate and Apache ActiveMQ, why so many connections?

我有一个web应用程序,一旦在由Spring MessageListener侦听的ActiveMQ上接收到消息,它就会在后台运行文本处理作业。。。。我遇到的问题是,一旦我处理了大约30个后台作业,ActiveMQ就会停止处理任何消息,Spring消息侦听器就会失去JMS连接,有时我会在ActiveMQ日志中收到一个错误,说打开的文件太多。

我在Linux上针对ActiveMQ进程运行了lsof(list open file)命令,并注意到对于JmsTemplate排队/发布/接收的几乎每个消息,都会打开一个新的连接。这正常吗?

这是我的配置:

<bean id="connectionFactory" class="org.springframework.jms.connection.CachingConnectionFactory">
    <constructor-arg ref="amqConnectionFactory" />
    <property name="exceptionListener" ref="jmsExceptionListener" />
    <property name="sessionCacheSize" value="100" />
</bean>
问题回答

您需要使用ActiveMQ提供的PooledConnectionFactory,您可以看到完整的配置此处。请确保阅读JmsTemplate Gotchas也一样。





相关问题
array dependency injection in spring?

is there a way to use dependency injection to inject all available implementations of a specific interface in spring? This is kind of the same thing as asked here for .NET. Though my aim is to use @...

Spring Properties File

Hi have this j2ee web application developed using spring framework. I have a problem with rendering mnessages in nihongo characters from the properties file. I tried converting the file to ascii using ...

Grails Packaging and Naming Conventions

Packaging Controllers, Services,etc. i.e. - com.company.controllers - com.company.services Is this a good practice or should be avoided by all means?? Another worth mentioning problem I encountered ...

How can I determine Objects in application context?

I am trying to write a portlet for Liferay (using Tomcat and Spring) and need to use a database via Persistence API/Hibernate. I am using some configuration XMLs (applicationContext.xml, etc.) and ...

How to prevent JPA from rolling back transaction?

Methods invoked: 1. Struts Action 2. Service class method (annotated by @Transactional) 3. Xfire webservice call Everything including struts (DelegatingActionProxy) and transactions is configured ...

热门标签