Author |
Message
|
justrob |
Posted: Tue Jun 01, 2004 11:34 am Post subject: Message ID |
|
|
Apprentice
Joined: 30 Apr 2004 Posts: 26
|
I have a JAVA client that is putting messages into a queue - that seemed to work for weeks... now it appears that it is using the same messageID on each message.
What needs to be done to ensure the JAVA client is using unique mesage id's?
Is it as simple as (MQPMO.Options) MQPMO_NEW_MSG_ID??
Thanks |
|
Back to top |
|
 |
kirani |
Posted: Tue Jun 01, 2004 10:47 pm Post subject: |
|
|
Jedi Knight
Joined: 05 Sep 2001 Posts: 3779 Location: Torrance, CA, USA
|
You go it! _________________ Kiran
IBM Cert. Solution Designer & System Administrator - WBIMB V5
IBM Cert. Solutions Expert - WMQI
IBM Cert. Specialist - WMQI, MQSeries
IBM Cert. Developer - MQSeries
|
|
Back to top |
|
 |
justrob |
Posted: Wed Jun 02, 2004 4:54 am Post subject: Thanks |
|
|
Apprentice
Joined: 30 Apr 2004 Posts: 26
|
Thanks for the response, I'll hassle the developer now |
|
Back to top |
|
 |
jigjim |
Posted: Mon Jun 07, 2004 12:36 pm Post subject: |
|
|
Apprentice
Joined: 30 Mar 2004 Posts: 41
|
That dosent work !!!
It keeps generating the same ID most of the times.
Instead i used this and it works :
msg.messageId = String.valueOf(Math.random()).getBytes();
Thanks
Jigs |
|
Back to top |
|
 |
jefflowrey |
Posted: Mon Jun 07, 2004 12:43 pm Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
jigjim wrote: |
That dosent work !!!
It keeps generating the same ID most of the times. |
Prove it!
You're probably trying to treat the message ID as a String, either for application purposes or for debugging purposes.
And that's not a valid procedure in either case.
http://www.mqseries.net/phpBB2/viewtopic.php?t=15736&highlight=message+id _________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
jigjim |
Posted: Mon Jun 07, 2004 1:12 pm Post subject: |
|
|
Apprentice
Joined: 30 Mar 2004 Posts: 41
|
I guess ur right on the part where non printable charachetrs makes it difficult to realise that the byte array will be different.
However since we need "bytes" to be assigned to messageID, I found my solution a quick, easy and relaible way to achive the purpose of generating unique random id's.
Why do you think it is not a valid "procedure" in either case.
I send the message onto teh Q using this id . then i pass the string variable to my read message function and set that as my read msg's correlation id. That way i get the response back to the rquest i sent?
Is there a better way to do it ?
Thanks
Jigs |
|
Back to top |
|
 |
jefflowrey |
Posted: Mon Jun 07, 2004 1:20 pm Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
jigjim wrote: |
I guess ur right on the part where non printable charachetrs makes it difficult to realise that the byte array will be different.
However since we need "bytes" to be assigned to messageID, I found my solution a quick, easy and relaible way to achive the purpose of generating unique random id's. |
It's not reliable at all, as long as it treats a byte array as a String in any fashion.
jigjim wrote: |
Why do you think it is not a valid "procedure" in either case. |
I didn't say your code wasn't valid. I said that it is not valid to treat a Byte array as a String.
jigjim wrote: |
I send the message onto teh Q using this id . then i pass the string variable to my read message function and set that as my read msg's correlation id. That way i get the response back to the rquest i sent?
Is there a better way to do it ? |
Yes. The better way to do it is to understand what you are actually using, which is a Byte array and not a String value.
Treating a Byte array as a String is the wrong thing to do. It's that simple.
Strings can contain only a subset of the possible values that Bytes can contain. You have no guarantees that any application you are talking to will make the same mistake and treat a Byte array as a String - and so you have no guarantees that you will get a response back to the request you send.
No guarantees at all.
Please read the manuals. Please. Please. _________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
jigjim |
Posted: Mon Jun 07, 2004 1:48 pm Post subject: |
|
|
Apprentice
Joined: 30 Mar 2004 Posts: 41
|
Thank you for the positive feedback.
Can you please refer to some of the manuals that I should read.
Also MQC.MQPMO_NEW_MSG_ID geneartes an "int" value which I will have to recast as bytes array. That should keep String out of the picture.
More importantly, i guess the gist of what you mean is:
Passing the String value to my msg retrieval function is incorrect. I should instead pass the bytes array so that it can be directly set as the corealtion id of my msg to be retrieved.
Can you pls pass/show some references on sample codes using the message ID and Corelation ID using Java.
Thanks
Jigs |
|
Back to top |
|
 |
EddieA |
Posted: Mon Jun 07, 2004 2:31 pm Post subject: |
|
|
 Jedi
Joined: 28 Jun 2001 Posts: 2453 Location: Los Angeles
|
Quote: |
Also MQC.MQPMO_NEW_MSG_ID geneartes an "int" value which I will have to recast as bytes array. That should keep String out of the picture. |
I think you're misunderstanding the use of this. MQPMO_NEW_MSG_ID is a value you set in the Put Message Options. It tells MQ to generate, and populate, a new MessageID in the message you are PUTting.
Start with the Application Programmers Guide, together with the Java manual. Then for reference, the Application Programmers Reference.
Cheers, _________________ Eddie Atherton
IBM Certified Solution Developer - WebSphere Message Broker V6.1
IBM Certified Solution Developer - WebSphere Message Broker V7.0 |
|
Back to top |
|
 |
|