Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

mq and Jms(ID's of request and reply do not match)??

Status
Not open for further replies.

gowri

Programmer
Oct 29, 2002
1
CA
I am sending a request to JMS (in xml format) however JMS does not honor this ID and designates a new ID to my reply..rendering it useless when it returns to the client. the designation of a new ID is compliant with the JMS spec. How can I get around this problem...should I use MQ native classes or cast my MQ classes in JMS?? here is some sample code..
else if (msg instanceof BytesMessage) {

BytesMessage inmsg = (BytesMessage) msg;
int bufferlength = 0;
byte[] buffer = new byte[4096];
bufferlength = inmsg.readBytes(buffer);
String strMessage = null;

try {
strMessage = new String(buffer,0,bufferlength, "UTF-8");
} catch (UnsupportedEncodingException e) {
exceptLog.debug("MessageCommand.run() - Unsupported Encoding");
}

exceptLog.debug("MessageCommand.run() - receiving BytesMessage:\n" + strMessage + "\n");

BytesMessage outmsg = mgr.createBytesMessage();
outmsg.clearBody();

// move the JMS correlation ID to the outgoing message

outmsg.setJMSCorrelationID(inmsg.getJMSCorrelationID());
outmsg.setJMSMessageID(inmsg.getJMSMessageID());

// get the ReplyTo queue set by the requestor

mgr.setProducer((Queue) inmsg.getJMSReplyTo());

// call the session facade

try {
outmsg.writeBytes(messageReceiver.processRequest(strMessage).getBytes("UTF-8"));
outmsg.reset();
} catch (UnsupportedEncodingException e) {
exceptLog.debug("MessageCommand.run() - Unsupported Encoding");
}

// send the message

mgr.sendMessage(outmsg, false);


if (persistent) {
msg.setJMSDeliveryMode(DeliveryMode.PERSISTENT);
} else {
msg.setJMSDeliveryMode(DeliveryMode.NON_PERSISTENT);
}
try {
((QueueSender)producer).send(msg);
} catch (Exception e) {
System.out.println("JmsMessageManager.sendMessage exception :" + e.getMessage());
e.printStackTrace();
}
}
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top