我没有收到任何回应。时间到。没有显示响应消息

时间:2019-06-28 06:12:33

标签: jms message-queue

connection = (MQQueueConnection) mqQueueConnectionFactory.createQueueConnection();
MQQueueSession session = (MQQueueSession) connection.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);
MQQueue queue = (MQQueue) session.createQueue("queue:///" + requestQueueName);
MQQueue responseQueue = (MQQueue) session.createQueue("queue:///" + responeQueueName);
MQQueueSender sender = (MQQueueSender) session.createSender(queue);
MQQueueReceiver receiver = (MQQueueReceiver) session.createReceiver(responseQueue);

isConnected = true;

System.out.println("-------- preparing request to send: ");

String messageString = requestString;

JMSTextMessage message = (JMSTextMessage) session.createTextMessage(messageString);
message.setJMSType("XML/MQ");
// message.setJMSReplyTo(responseQueue);

connection.start();

sender.send(message);
JMSMessage receivedMessage = (JMSMessage) receiver.receive(TIMEOUT);
System.out.println("-------- recieved JMSMessage is: \n" + receivedMessage);
sender.close();
receiver.close();
session.close();
connection.close();
System.out.println("-------- getting response: ");
responseXMLString = receivedMessage != null ? ((JMSTextMessage) receivedMessage).getText() : "No response recieved. Timed Out";

0 个答案:

没有答案