I tested a standalone JMS client passing a TextMessage
to a queue on IBM MQ, and I got the below message id with error:
ID:414d51204243573032413154202020205bc6bd3e25423865
java.lang.RuntimeException: no text message
- I sent a
TextMessage
withThis is for Test
, but why didn't I receive aTextMessage
? There were no other messages in the queue before this code ran. - In case text message success how to read the message Id (send request MessageID and reply message Id) in readable format in Java. Is any thing I need to change in the below code.
TextMessage textMessage = queueSession.createTextMessage("This is for Test");
textMessage.setJMSReplyTo(queue);
textMessage.setJMSType("mcd://xmlns");//message type
textMessage.setJMSExpiration(2*1000);//message expiration
textMessage.setJMSDeliveryMode(DeliveryMode.PERSISTENT);
queueSender = queueSession.createSender(queueSession.createQueue(outputQName));
queueSender.setTimeToLive(2*1000);
queueSender.send(textMessage);
String jmsCorrelationID = " JMSCorrelationID = '" + textMessage.getJMSMessageID() + "'";
while (true) {
Message message = queueReceiver.receive(60*1000);
if (! (message instanceof TextMessage))
throw new RuntimeException("no text message");
TextMessage tm = (TextMessage) message;
System.out.println("Message:"+tm.getText());
}