|
RSS Feed - WebSphere MQ Support
|
RSS Feed - Message Broker Support
|
 |
|
How to get queuemanger generated messageid in java after put |
« View previous topic :: View next topic » |
Author |
Message
|
chandra |
Posted: Fri Nov 16, 2012 11:10 am Post subject: How to get queuemanger generated messageid in java after put |
|
|
Newbie
Joined: 16 Nov 2012 Posts: 2
|
Hi,
Can somebody help on to get the message Id which is generated by queuemanger after put.
In my application, we have delay in reply, so we are using listener to read message instead of real time reply read. I need to get the message Id while putting message in request queue.
below is my code :
MQMessage msg = new MQMessage();
msg.setVersion(1);
.......
msg.format = "MQSTR";
msg.priority = "0";
msg.persistence = "0"
//msg.messageId = "54567989809009".getBytes();
//msg.correlationId = "555555555567".getBytes();
msg.replyToQueueName = replyQueueName;
msg.replyToQueueManagerName = replyqueuemangerName;
........................
requestQueue.put(msg);
System.out.println("Message id generated of msg after put >>"+msg.messageId+"<<<");
Output :
Message id generated of msg after put >> [B@16041604 |
|
Back to top |
|
 |
RogerLacroix |
Posted: Fri Nov 16, 2012 5:50 pm Post subject: Re: How to get queuemanger generated messageid in java after |
|
|
 Jedi Knight
Joined: 15 May 2001 Posts: 3264 Location: London, ON Canada
|
chandra wrote: |
System.out.println("Message id generated of msg after put >>"+msg.messageId+"<<<");
Output :
Message id generated of msg after put >> [B@16041604 |
Yes, that is correct. "messageId" is a byte array field (24 bytes to be exact). This isn't an MQ question but rather a Java question. How do you normally deal with byte array fields?
You need to do this:
Code: |
System.out.println("Message id generated of msg after put >>"+byteArrayToHexString(msg.messageId)+"<<<"); |
And here is the byteArrayToHexString method:
Code: |
/**
* Convert a byte array to a hex string representation
* @param byteArray
* @return string
*/
public static String byteArrayToHexString(byte[] byteArray)
{
int len = byteArray.length;
StringBuffer hexStr = new StringBuffer();
for (int j=0; j < len; j++)
hexStr.append(byteToHex((char)byteArray[j]));
return hexStr.toString();
}
/**
* Convert a byte to its hexadecimal value.
* @param val
* @return
*/
private static String byteToHex(char val)
{
int hi = (val & 0xF0) >> 4;
int lo = (val & 0x0F);
return "" + HEX.charAt(hi) + HEX.charAt(lo);
}
private static final String HEX = "0123456789ABCDEF"; |
Regards,
Roger Lacroix
Capitalware Inc. _________________ Capitalware: Transforming tomorrow into today.
Connected to MQ!
Twitter |
|
Back to top |
|
 |
chandra |
Posted: Fri Nov 16, 2012 8:28 pm Post subject: |
|
|
Newbie
Joined: 16 Nov 2012 Posts: 2
|
Thanks a lot Roger,
Yes I find this a an hour ago that I need to convert and it got resolved. Thanks for reply |
|
Back to top |
|
 |
|
|
 |
|
Page 1 of 1 |
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|
|
|