JmsTemplate has no send timeout

anshulkatta picture anshulkatta · Aug 8, 2013 · Viewed 7.4k times · Source

I have working JMS application with IBM MQ jars configuration , using spring

It works well with correct queue information , but when i give wrong queue information

it is hung at

LOG.info("SENDING MESSAGE");
jmsTemplate.send(this.getDestination(), messageCreator );  //here

I have my Log saying sending message , i am handling org.springframework.jmsexception , but it does not throw.....i think it is hung at that point.

I am not able to find any property for jmstemplate for send timeout , only for recieve timeout is there...

Here is jmstemplate conf in app-context.xml (Spring)

<bean id="jmsTemplate" class="org.springframework.jms.core.JmsTemplate102">
        <property name="connectionFactory">
            <ref bean="jmsQueueConnectionFactory" />
        </property>
        <property name="destinationResolver">
            <ref bean="jmsDestinationResolver" />
        </property>
        <property name="pubSubDomain">
            <value>false</value>
        </property>
        <property name="receiveTimeout">
            <value>20000</value>

        </property>

and ibm mq conf -

<bean id="mqConnectionFactory" class="com.ibm.mq.jms.MQQueueConnectionFactory">
        <property name="hostName">
            <value>${queue_hostname}</value>
        </property>
        <property name="port">
            <value>${queue_port}</value>
        </property>
        <property name="queueManager">
            <value>${queue_manager}</value>
        </property>
        <property name="channel">
            <value>${queue_channel}</value>
        </property>
        <property name="transportType">
            <value>1</value>
        </property>
    </bean>

I have set it to Auto-acknowledge

this.jmsTemplate.setSessionAcknowledgeMode(Session.AUTO_ACKNOWLEDGE);

So please tell me how to have timeout on sending message to throw jmsexception.

Answer

Roger picture Roger · Aug 8, 2013

This is all non sense.

If you attempt to put a message to an invalid queue, MQ IMMEDIATELY throws an exception with a reason code 2085 (unknown object). There is no timeout required. Obviously, the framework you are using has a bug in it that it is not catching the thrown exception!!!

Try the same test using just JMS and MQ, and you will see the difference.