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 » JAVA API MSG ID

Post new topic  Reply to topic
 JAVA API MSG ID « View previous topic :: View next topic » 
Author Message
meetgaurav
PostPosted: Wed Dec 31, 2008 12:52 am    Post subject: JAVA API MSG ID Reply with quote

Voyager

Joined: 08 Sep 2008
Posts: 94

Hi FJ

I tried to set the message ID as BSC and NSC(For testing Purpose).. But I was not able to set. Could you plz assist me.

public static byte[] toByteArray(String hexStr)
{
byte msgId[] = new byte[hexStr.length()/2];
for(int i=0; i<(hexStr.length()/2); i++)
{
byte firstNibble = Byte.parseByte(hexStr.substring(2*i,2*i+1),16);
byte secondNibble = Byte.parseByte(hexStr.substring(2*i+1,2*i+2),16);
int finalByte = (secondNibble) | (firstNibble << 4 );
msgId[i] = (byte) finalByte;
}
return msgId;
}

This is working fine.. But only for HEXA string. Since 'S' is not a hexa am getting some error. Plz assist
Back to top
View user's profile Send private message
Vitor
PostPosted: Wed Dec 31, 2008 1:14 am    Post subject: Re: JAVA API MSG ID Reply with quote

Grand High Poobah

Joined: 11 Nov 2005
Posts: 26093
Location: Texas, USA

meetgaurav wrote:
Hi FJ


Despite not being FJ, I leap into the quicksand-infested swamp of Java...

meetgaurav wrote:
I tried to set the message ID as BSC and NSC(For testing Purpose)


Why? What testing needs a set msg id (which presumably is not in use long term)? What are you trying to achieve (so that we might suggest alternatives)?

meetgaurav wrote:
am getting some error. Plz assist


More details on the error might help with the assistance...
_________________
Honesty is the best policy.
Insanity is the best defence.
Back to top
View user's profile Send private message
meetgaurav
PostPosted: Wed Dec 31, 2008 2:06 am    Post subject: Reply with quote

Voyager

Joined: 08 Sep 2008
Posts: 94

Actually in real time I will get message Id's as NSC and BSC followed by some numbers. According to this ID my backend packages and procedures will work..

Now everytime am hardcoding the message Id in the MDB and deploying.. I need a code to set the Message Id as NSC123 or BSC123.

Please Assist
Back to top
View user's profile Send private message
Vitor
PostPosted: Wed Dec 31, 2008 2:12 am    Post subject: Reply with quote

Grand High Poobah

Joined: 11 Nov 2005
Posts: 26093
Location: Texas, USA

meetgaurav wrote:
Actually in real time I will get message Id's as NSC and BSC followed by some numbers. According to this ID my backend packages and procedures will work..


Oh Dear.

This is a really, really bad design idea. There are numerous posts on this in the forum surrounding this topic. It's a bad idea to put business data in the id fields; it's a worse idea to pretend they're strings.

Don't do it. You're storing up trouble for the future. Use one of the fields designated for your business data; it will work so much better. Leave the id fields to the queue manager.
_________________
Honesty is the best policy.
Insanity is the best defence.
Back to top
View user's profile Send private message
Vitor
PostPosted: Wed Dec 31, 2008 2:22 am    Post subject: Reply with quote

Grand High Poobah

Joined: 11 Nov 2005
Posts: 26093
Location: Texas, USA

meetgaurav wrote:
Now everytime am hardcoding the message Id in the MDB and deploying.. I need a code to set the Message Id as NSC123 or BSC123.


This is the point where you need FJ or someone who knows Java, but are you certain you can set a message id in JMS? There's a voice in the back of my head saying it's not allowed.

Mind you, this is the same voice that periodically tells me to kill, kill, kill so not that reliable.

Perhaps more details of the error...?

I stand by my previous comments however; even if you can do this technically, you shouldn't.
_________________
Honesty is the best policy.
Insanity is the best defence.
Back to top
View user's profile Send private message
fjb_saper
PostPosted: Wed Dec 31, 2008 3:37 am    Post subject: Reply with quote

Grand High Poobah

Joined: 18 Nov 2003
Posts: 20756
Location: LI,NY

JMS conforms to a standard and some best practice rules.
As such it is NOT possible to set the JMSMessageId in JMS. It is being set by the qmgr and is a read only value.

If it is unique, you could set the JMSCorrelationId. There are a few methods here but remember that if your destination (targetClient) is non JMS you are limited to 24 bytes.
_________________
MQ & Broker admin
Back to top
View user's profile Send private message Send e-mail
Vitor
PostPosted: Wed Dec 31, 2008 3:45 am    Post subject: Reply with quote

Grand High Poobah

Joined: 11 Nov 2005
Posts: 26093
Location: Texas, USA

fjb_saper wrote:
As such it is NOT possible to set the JMSMessageId in JMS. It is being set by the qmgr and is a read only value.


Yay me! Got a Java question right!

(I wonder if this means the voice is right about other things.... )

fjb_saper wrote:
If it is unique, you could set the JMSCorrelationId. There are a few methods here but remember that if your destination (targetClient) is non JMS you are limited to 24 bytes.


IMHO you're still better off leaving the ids alone. Use the correl id for this & 2 years down the line you'll be beating your head against the desk because suddenly they want request/reply...
_________________
Honesty is the best policy.
Insanity is the best defence.
Back to top
View user's profile Send private message
fjb_saper
PostPosted: Wed Dec 31, 2008 3:49 am    Post subject: Reply with quote

Grand High Poobah

Joined: 18 Nov 2003
Posts: 20756
Location: LI,NY

For the nth time here is the official answer:
Quote:
JMSMessageID from MQMD.MessageID
All messages sent from JMS have unique message identifiers assigned by WebSphere® MQ. The value assigned is returned in the MQMD.MessageId field after the MQPUT call, and is passed back to the application in the JMSMessageID field. The WebSphere MQ messageId is a 24-byte binary value, whereas the JMSMessageID is a string. The JMSMessageID is composed of the binary messageId value converted to a sequence of 48 hexadecimal characters, prefixed with the characters ID:. JMS provides a hint that can be set to disable the production of message identifiers. This hint is ignored, and a unique identifier is assigned in all cases. Any value that is set into the JMSMessageId field before a send() is overwritten.


See the manual and some more.
Using the manual's search facility it took me less than five mins to find it.
_________________
MQ & Broker admin
Back to top
View user's profile Send private message Send e-mail
mqjeff
PostPosted: Wed Dec 31, 2008 6:59 am    Post subject: Reply with quote

Grand Master

Joined: 25 Jun 2008
Posts: 17447

That said, if you do actually have this really really bad business requirement, then in order to meet it you will have to use the Java API for WebSphere MQ and not the JMS API.

In addition, you should rework your "toByteString" code entirely. That many substrings is going to be horrid for performance, and there's basically got to be a far simpler way to produce the result you want.

And you likely don't need to do it anyway, just create byte[] from your String, rather than create a String that contains the Hex values of your bytes.
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 » JAVA API MSG ID
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.