ASG
IBM
Zystems
Cressida
Icon
Netflexity
 
  MQSeries.net
Search  Search       Tech Exchange      Education      Certifications      Library      Info Center      SupportPacs      LinkedIn  Search  Search                                                                   FAQ  FAQ   Usergroups  Usergroups
 
Register  ::  Log in Log in to check your private messages
 
RSS Feed - WebSphere MQ Support RSS Feed - Message Broker Support

MQSeries.net Forum Index » IBM MQ Java / JMS » How to get queuemanger generated messageid in java after put

Post new topic  Reply to topic
 How to get queuemanger generated messageid in java after put « View previous topic :: View next topic » 
Author Message
chandra
PostPosted: Fri Nov 16, 2012 11:10 am    Post subject: How to get queuemanger generated messageid in java after put Reply with quote

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
View user's profile Send private message
RogerLacroix
PostPosted: Fri Nov 16, 2012 5:50 pm    Post subject: Re: How to get queuemanger generated messageid in java after Reply with quote

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
View user's profile Send private message Visit poster's website
chandra
PostPosted: Fri Nov 16, 2012 8:28 pm    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Post new topic  Reply to topic Page 1 of 1

MQSeries.net Forum Index » IBM MQ Java / JMS » How to get queuemanger generated messageid in java after put
Jump to:  



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
Protected by Anti-Spam ACP
 
 


Theme by Dustin Baccetti
Powered by phpBB © 2001, 2002 phpBB Group

Copyright © MQSeries.net. All rights reserved.