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();
}
}
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();
}
}