Spring JmsTemplate & WebSphere MQ - 忽略 RECEIVE_TIMEOUT_NO_WAIT
我正在使用 Spring JmsTemplate 和 WebSphere MQ(在 WebSphere App Server 内)。
我按如下方式创建 JmsTemplate 实例:
def templateFor(managerJndiName: String) = {
val connectionFactory = context.lookup(managerJndiName).asInstanceOf[QueueConnectionFactory]
val jmsTemplate = new JmsTemplate(connectionFactory)
jmsTemplate.setReceiveTimeout(JmsTemplate.RECEIVE_TIMEOUT_NO_WAIT)
jmsTemplate
}
注意,我将超时设置为 no_wait (-1)。然而,线程仍然阻塞。
[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.JmqiTools.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)
我错过了什么?
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.JmqiTools.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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
由于此问题的评论 我以为我用的是Spring 3,结果我用的是Spring 1,看代码,Spring 1不支持RECEIVE_TIMEOUT_NO_WAIT
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