- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
似乎JMSProducer
没有进行垃圾收集,并且在将消息传递到队列后保持 Activity 状态,我正在使用Spring 3.2.2和带有Keep-alive设置的CachingConnectionFactory
用于发送消息。
每次我发送消息时,生产者数量都会不断增加。
与我使用的spring版本有关吗?
或者我的配置做错了什么?
最佳答案
您需要调用 close()
method在您的MessageProducer
上。根据 Java 文档:-
void close()
throws JMSExceptionCloses the message producer.
Since a provider may allocate some resources on behalf of a
MessageProducer
outside the Java virtual machine, clients should close them when they are not needed. Relying on garbage collection to eventually reclaim these resources may not be timely enough.
根据 Spring CachingConnectionFactory 文档:-
NOTE: This ConnectionFactory requires explicit closing of all Sessions obtained from its shared Connection. This is the usual recommendation for native JMS access code anyway. However, with this ConnectionFactory, its use is mandatory in order to actually allow for Session reuse.
因此,您需要调用 getCachedSessionProxy 而不是 getSession ,并在发送消息后调用 close() (在 finally block 中)。根据源代码,处理对此 session 代理的关闭调用,以便重用 session 和消息生产者。加里的评论也是如此。
关于java - 使用 CachingConnectionFactory 时未清理生产者,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25306857/
似乎JMSProducer没有进行垃圾收集,并且在将消息传递到队列后保持 Activity 状态,我正在使用Spring 3.2.2和带有Keep-alive设置的CachingConnectionF
我们在 Tomcat (7.0.41) 中使用 Spring (3.2.4) 和 ActiveMQ (5.8.0),目前尚不清楚最佳用法。我们想用 JmsTemplate 来生产,用 MessageL
Spring 配置 MyService.java
我在使用 ActiveMQ 和 Spring 的 CachingConnectionFactory 时遇到问题。我正在这样设置它们:
当使用 spring-jms 时,spring 提供了 2 个用于连接和 session 缓存的选项,以提高性能。 使用 CachingConnectionFactory 并缓存 session ,您
我正在使用 Apache Camel 和 Spring 从我的 Java 服务发送消息。如果交换时发生任何错误,我需要重置 JMS 连接。我正在使用下面的代码来实现我的目标。 try { pr
Java 文档 here与 Spring CachingConnectionFactory 相关的评论: NOTE: This ConnectionFactory requires explicit
我们正在使用 Spring 的 CachingConnectionFactory 在我们的应用程序的生产中每天处理数千万条消息,并且效果良好。 但是,我们希望减少与 Solace 的并发连接量,直到需
我正在使用 JmsTemplate 从同一客户端连接到两个 IBM MQ 服务器。 我已经配置了 JmsTemplate 的 reconnectOnException 以及 IBM MQ 连接工厂的
根据关于在 hornetq 中使用 JMSTemplate 的长期信息,我们在连接到服务器时一直在使用 CachingConnectionFactory。这是一个示例配置,与我们正在使用的配置非常相似
我们使用 Spring AMQP 客户端连接到我们的 RabbitMQ,我们的 Spring 配置定义为 nativeCF 指向基本的 Java 客户端实现 ConnectionFactory。
我有一个基于 spring-integration 4.0.x 的应用程序,它连接到 Websphere MQ 管理器以生成/使用 JMS 消息。该应用程序当前部署在 Tomcat 7.0.x 容器上
我们刚刚升级到 Spring 4 和 JMS 2.0。我们正在使用 CachingConnectionFactory 和 JmsTemplate 发布消息,并注意到在发布到目的地时,第一次尝试有效,然
我是一名优秀的程序员,十分优秀!