I am using Spring JmsTemplate and WebSphere MQ (inside WebSphere App Server).
I create the JmsTemplate instance as follows:
def templateFor(managerJndiName: String) = {
val connectionFactory = context.lookup(managerJndiName).asInstanceOf[QueueConnectionFactory]
val jmsTemplate = new JmsTemplate(connectionFactory)
jmsTemplate.setReceiveTimeout(JmsTemplate.RECEIVE_TIMEOUT_NO_WAIT)
jmsTemplate
}
Note, I set the timeout to be no_wait (-1). However, the thread still blocks.
[5/26/11 11:53:32:183 EST] 0000003d TimeoutManage I WTRN0124I: When the timeout occurred the thread with which the transaction is, or was most recently, associated was Thread[Default : 2,5,main]. The stack trace of this thread when the timeout occurred was:
java.lang.Object.wait(Native Method)
java.lang.Object.wait(Object.java:167)
com.ibm.mq.jmqi.remote.internal.system.RemoteProxyQueue.proxyMQGET(RemoteProxyQueue.java:2585)
com.ibm.mq.jmqi.remote.internal.RemoteFAP.jmqiGetMessage(RemoteFAP.java:5603)
com.ibm.mq.jmqi.internal.JmqiTool开发者_JAVA技巧s.getMessage(JmqiTools.java:1056)
com.ibm.mq.jmqi.remote.internal.RemoteFAP.jmqiGet(RemoteFAP.java:5540)
com.ibm.msg.client.wmq.internal.WMQConsumerShadow.getMsg(WMQConsumerShadow.java:1169)
com.ibm.msg.client.wmq.internal.WMQSyncConsumerShadow.receiveInternal(WMQSyncConsumerShadow.java:233)
com.ibm.msg.client.wmq.internal.WMQConsumerShadow.receive(WMQConsumerShadow.java:922)
com.ibm.msg.client.wmq.internal.WMQMessageConsumer.receive(WMQMessageConsumer.java:450)
com.ibm.msg.client.jms.internal.JmsMessageConsumerImpl.receiveInboundMessage(JmsMessageConsumerImpl.java:742)
com.ibm.msg.client.jms.internal.JmsMessageConsumerImpl.receive(JmsMessageConsumerImpl.java:321)
com.ibm.mq.jms.MQMessageConsumer.receive(MQMessageConsumer.java:228)
com.ibm.ejs.jms.JMSMessageConsumerHandle.receive(JMSMessageConsumerHandle.java:444)
org.springframework.jms.core.JmsTemplate.doReceive(JmsTemplate.java:669)
org.springframework.jms.core.JmsTemplate.doReceive(JmsTemplate.java:657)
org.springframework.jms.core.JmsTemplate$8.doInJms(JmsTemplate.java:613)
org.springframework.jms.core.JmsTemplate.execute(JmsTemplate.java:432)
org.springframework.jms.core.JmsTemplate.receive(JmsTemplate.java:611)
mypackage.MessageQueue.readMessage(MessageQueue.scala:86)
What have I missed?
Because of the hack outlined in the comments of this question I thought I was using Spring 3, but I was using Spring 1. Looking at the code, Spring 1 does not support RECEIVE_TIMEOUT_NO_WAIT
精彩评论