0

我正在使用 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)

我错过了什么?

4

1 回答 1

0

由于这个问题的评论中概述的黑客,我以为我使用的是 Spring 3,但我使用的是 Spring 1。查看代码,Spring 1 不支持 RECEIVE_TIMEOUT_NO_WAIT

于 2011-05-26T02:39:23.057 回答