1

I have a Batch Job Configured to read messages from JMS Destination and write to a XML file using Chuck Tasklet. The JMS reader is custom implemented which inturn invokes JMSTemplate's receive method. I am using webMethods Broker as JMS Broker. During Batch run, we observed that the Consumer session created while reading the messages from Broker Destination are not being destroyed up on completion of the batch. They are only destroyed after I shutdown the JVM. I have provided more details below,

JMS Spring XML Configuration :

<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>

Any help on pointing out the actual issue would be great.

anand206
  • 21
  • 5

1 Answers1

0

Call destroy() on the JMS.SourceQueue.ConnectionFactory at the end of the last step (or otherwise when the job is completed).

Using the caching connection factory is recommended to avoid creating connections/consumers for each message, but it needs to be told when to physically release the resources.

Gary Russell
  • 166,535
  • 14
  • 146
  • 179