gpt4 book ai didi

java - Spring : JMS Consumer Sessions/Connections not removed on Message Broker post Batch Job Completion

转载 作者:太空宇宙 更新时间:2023-11-04 14:35:34 28 4
gpt4 key购买 nike

我有一个批处理作业,配置为从 JMS 目标读取消息并使用 Chuck Tasklet 写入 XML 文件。 JMS 读取器是自定义实现的,它反过来调用 JMSTemplate 的接收方法。我使用 webMethods Broker 作为 JMS Broker。在批处理运行期间,我们观察到从代理目标读取消息时创建的消费者 session 在批处理完成后不会被销毁。它们仅在我关闭 JVM 后才会被销毁。我在下面提供了更多详细信息,

JMS Spring XML 配置:

<bean id="JMS.SourceQueue.JndiTemplate" class="org.springframework.jndi.JndiTemplate">
<property name="environment">
<map>
<entry key="java.naming.provider.url" value="wmjmsnaming://Broker #1@X.X.X.X:6849" />
<entry key="java.naming.factory.initial" value="com.webmethods.jms.naming.WmJmsNamingCtxFactory" />
<entry key="com.webmethods.jms.naming.clientgroup" value="IS-JMS" />
</map>
</property>
</bean>
<bean id="JMS.SourceQueue.JmsConnectionFactory" class="org.springframework.jndi.JndiObjectFactoryBean">
<property name="jndiTemplate" ref="JMS.SourceQueue.JndiTemplate" />
<property name="jndiName" value="SmartBatchConnectionFactory" />
<property name="lookupOnStartup" value="true" />
<property name="cache" value="false" />
<property name="proxyInterface" value="javax.jms.ConnectionFactory" />
</bean>
<bean id="JMS.SourceQueue.ConnectionFactory"
class="org.springframework.jms.connection.CachingConnectionFactory">
<constructor-arg ref="JMS.SourceQueue.JmsConnectionFactory" />
</bean>
<bean id="JMS.SourceQueue.DefaultDestination" class="org.springframework.jndi.JndiObjectFactoryBean">
<property name="jndiTemplate" ref="JMS.SourceQueue.JndiTemplate" />
<property name="jndiName" value="SourceQueue" />
</bean>
<bean id="JMS.SourceQueue.MessageTemplate" class="org.springframework.jms.core.JmsTemplate">
<property name="connectionFactory" ref="JMS.SourceQueue.ConnectionFactory" />
<property name="receiveTimeout" value="10000" />
<property name="sessionTransacted" value="true" />
<property name="defaultDestination" ref="JMS.SourceQueue.DefaultDestination" />
</bean>

任何有关指出实际问题的帮助都会很棒。

最佳答案

在最后一个步骤结束时(或者当作业完成时)调用JMS.SourceQueue.ConnectionFactory上的destroy() )。

建议使用缓存连接工厂以避免为每条消息创建连接/使用者,但需要告知何时物理释放资源。

关于java - Spring : JMS Consumer Sessions/Connections not removed on Message Broker post Batch Job Completion,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25631355/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com