【问题标题】:Not receiving reply on Websphere MQ temporary queue未在 Websphere MQ 临时队列上收到回复
【发布时间】:2014-04-30 20:28:29
【问题描述】:

我正在使用 Websphere MQ 系统的发送/接收机制。

我以文本格式发送的 xml 应该会收到回复,但是我没有收到回复。

我知道 xml 正在“发送”正常,因为目标系统中的“事情正在发生” - 只是我没有收到回复。回复对我来说很重要,因为如果某些事情失败了,它可能会包含一条错误消息。

所以,我没有收到回复的原因 - 我不确定我的代码或 Websphere MQ 配置是否有问题。

非常感谢任何关于我的代码的指针或我应该要求 Websphere MQ 管理员查看的内容!

展示接收未发生的小型自包含示例如下所示:

public class CustomQueueConnection {
    private MQQueueConnectionFactory connectionFactory;
    private MQQueueConnection connection;

    private void runTest() throws JMSException {
        connect();
        MQQueueSession session = (MQQueueSession) connection.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);
        MQQueue queue = (MQQueue) session.createQueue("queue:///REQ_SNAPSHOT.HT");
        MQQueueSender sender = (MQQueueSender) session.createSender(queue);
        TemporaryQueue temporaryQueue = session.createTemporaryQueue();
        MQQueueReceiver receiver = (MQQueueReceiver) session.createReceiver(temporaryQueue);

        TextMessage message = session.createTextMessage(
                "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n" +
                // my well constructed xml goes here...
        );

        message.setJMSReplyTo(temporaryQueue);
        sender.send(message);
        System.out.println("Sent: " + message);
        JMSMessage receivedMessage = (JMSMessage) receiver.receive(10000);
        System.out.println("Received: " + receivedMessage);
    }

    public boolean connect() {
        boolean connected = false;
        try {
            connectionFactory = new MQQueueConnectionFactory();
            connectionFactory.setCCSID(819);
            connectionFactory.setPort(1417);
            connectionFactory.setHostName("1.2.3.4");
            connectionFactory.setQueueManager("GATE1");
            connectionFactory.setChannel("CLIENTS.CHANNEL");
            connectionFactory.setTemporaryModel("GATEWAY_MODEL_QUEUE");
            connectionFactory.setTempQPrefix("MACHINE.USER_NAME.*");
            connectionFactory.setTransportType(JMSC.MQJMS_TP_CLIENT_MQ_TCPIP);

            connection = (MQQueueConnection) connectionFactory.createQueueConnection();
            connected = true;
        } catch (JMSException e) {
            connected = false;
        }
        return connected;
    }

    public static void main(String[] args) throws JMSException {
        new CustomQueueConnection().runTest();
    }

}

这是输出:

Sent:
        JMS Message class: jms_text
        JMSType:         null
        JMSDeliveryMode: 2
        JMSExpiration:   0
        JMSPriority:     4
        JMSMessageID:    ID:414d512050314f47415445312020202053599032201b4d05
        JMSTimestamp:    1398680728618
        JMSCorrelationID:null
        JMSDestination:  queue:///REQ_SNAPSHOT.HT
        JMSReplyTo:      queue://GATE1/MACHINE.USER_NAME.53599032201B4E04?persistence=1
        JMSRedelivered:  false
        JMS_IBM_PutDate:20140428
        JMSXAppID:WebSphere MQ Client for Java
        JMS_IBM_PutApplType:28
        JMSXUserID:aomis
        JMS_IBM_PutTime:10252859
        JMSXDeliveryCount:0
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<esb:esbMessage xmlns:esb="http://ESBServices
        Another 557 character(s) omitted
        Received: null

(注意:已收到:null)

编辑:Websphere MQ 版本是 6.0.25

【问题讨论】:

    标签: java jms ibm-mq


    【解决方案1】:

    您的代码在我看来没问题,消息发送成功。我想让你检查一下:

    1) 是否有应用程序正在运行以接收来自 REQ_SNAPSHOT.HT 队列的消息?

    2) 假设有一个应用程序正在运行并接收消息,该应用程序是否成功处理了传入的 XML 消息?它会抛出任何异常吗?

    3) 如果传入的消息处理成功,它是否将回复放入正确的回复队列“MACHINE.USER_NAME.53599032201B4E04”?检查它在放置回复消息时是否遇到任何问题。

    【讨论】:

    • 嗨Shashi,我无法直接访问其他系统,但我可以“看到”正确发生的事情,所以我认为1)和2)是是的。对于问题 3,我想我应该要求系统管理员使用某种管理工具来查看是否将消息放置在该队列中(或没有)?
    【解决方案2】:

    解决方案是双重的。

    首先,连接需要在创建后立即启动

            connect();
            connection.start();
    

    其次,需要用DeliveryMode.NON_PERSISTENT发送消息。

    【讨论】:

      猜你喜欢
      • 2012-03-19
      • 1970-01-01
      • 1970-01-01
      • 2013-12-18
      • 1970-01-01
      • 2016-04-24
      • 2010-11-12
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多