|
RSS Feed - WebSphere MQ Support
|
RSS Feed - Message Broker Support
|
 |
|
How to identify messages before retrieving |
« View previous topic :: View next topic » |
Author |
Message
|
Rohitash |
Posted: Thu Oct 06, 2005 9:15 am Post subject: How to identify messages before retrieving |
|
|
Newbie
Joined: 03 Oct 2005 Posts: 5 Location: Bangalore, INDIA
|
Hi
I want to set some parameter of the messages before putting them in the queue( like correlationID). When i retrieve the messages, i want to check this parameter and retrieve all the messages based on this information in the message header. I tried setting different correlation ids for different messages and wrote a program to retrieve all the messages having the same correlation ID. It is working. The correlation ID is being set in the following way:-
While Sending:-
MQMessage hello_world1.writeString( "One last try000");
String corrId= "Accounts";
byte[] b1 =corrId.getBytes();
hello_world1.correlationId= b1;
While recieving :-
byte[] correlationId1 = retrievedMessage1[icount].correlationId;
strCorrelationId1 = new String(correlationId1).trim();
I want to know if i can do the same task with some other parameter of the message header for eg:- groupId, applicationIdData,etc. I tried doing it with groupId and applicationIdData. While reading the message, it contains a blank value for both groupId and applicationIdData. So i am unable to compare them with a String value.
The second problem is that when I get a messageId, it is in byte[] form. When i convert it to string, i tried two ways:-
1)
messageId = retrievedMessage1icount].messageId.toString().trim();
The first one gives a value which is something like
message Id:[B@a20892
String message Id:[B@a20892
2) //messageId = new String(retrievedMessage1[i].messageId).trim();
The second one gives a messageId consisting of junk characters.
Which of the follwoing is used to get the messageId and store it to identify the message? Do we convert it to string or is there some other way of dealing with it?
Please help me with this problem.
_________________ Thanks and regards
Rohitash Laul |
|
Back to top |
|
 |
EddieA |
Posted: Thu Oct 06, 2005 10:17 am Post subject: |
|
|
 Jedi
Joined: 28 Jun 2001 Posts: 2453 Location: Los Angeles
|
Oh dear, here we go again.
Everybody repeat after me: Do not try and treat MessageID and CorrelationID as strings. They are NOT, they are bytes.
Quote: |
wrote a program to retrieve all the messages having the same correlation ID
byte[] correlationId1 = retrievedMessage1[icount].correlationId;
|
This looks like you actually read every message, and then matched the ID. I'd suggest reading the manuals on how to read messages based on MessageID and/or CorrelationID.
And don't try and use MQ as a form of database. It isn't.
Cheers, _________________ Eddie Atherton
IBM Certified Solution Developer - WebSphere Message Broker V6.1
IBM Certified Solution Developer - WebSphere Message Broker V7.0 |
|
Back to top |
|
 |
Rohitash |
Posted: Thu Oct 06, 2005 7:48 pm Post subject: Reply:How to identify messages before retrieving |
|
|
Newbie
Joined: 03 Oct 2005 Posts: 5 Location: Bangalore, INDIA
|
Hi
Thank you for the reply. My first question is still unanswered. I want to know if we can use any other parameters besides correlation Id to identify messages while browsing on the queue and gettin the message only if it matches. I am converting the correlation Id to string and then comparing with another string. I am using the following options for browsing the messages:-
gmo1.options = MQC.MQGMO_WAIT | MQC.MQGMO_BROWSE_FIRST;
gmo1.options = MQC.MQGMO_WAIT | MQC.MQGMO_BROWSE_NEXT;
Suppose i set correlation Id ="ABC" for some of the messages in the queue. After browsing, I will store all the messages with corr Id ="ABC" in an arraylist and then get them from the arraylist one by one. Can i use any other field instead of correlationID?
Now that we are not supposed to convert the messageId and correlationId to String, how will we track the messages for referring to a message and for logging ? I thought of doing it by messageId because it is unique for all the messages.
Please help me with this issue. _________________ Thanks and regards
Rohitash Laul |
|
Back to top |
|
 |
fjb_saper |
Posted: Thu Oct 06, 2005 8:08 pm Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
You may use a hex representation of all the bytes in the array for logging and print purposes.
Knowing that when it comes to it you have to use a byte array...
Enjoy  |
|
Back to top |
|
 |
EddieA |
Posted: Fri Oct 07, 2005 8:07 am Post subject: |
|
|
 Jedi
Joined: 28 Jun 2001 Posts: 2453 Location: Los Angeles
|
The non-JMS APIs only supports GETting a message directly by MessageID and/or CorrelationID.
The JMS Selectors will allow you to GET a message by specifying other fields, but beware, that they do it by Browsing the Queue to find the matching message.
Cheers, _________________ Eddie Atherton
IBM Certified Solution Developer - WebSphere Message Broker V6.1
IBM Certified Solution Developer - WebSphere Message Broker V7.0 |
|
Back to top |
|
 |
fjb_saper |
Posted: Fri Oct 07, 2005 9:04 am Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
EddieA wrote: |
The non-JMS APIs only supports GETting a message directly by MessageID and/or CorrelationID.
The JMS Selectors will allow you to GET a message by specifying other fields, but beware, that they do it by Browsing the Queue to find the matching message.
Cheers, |
Add as soon as you differ from the native(implementer) form which is restricted to messageid and correlation id ? : field = "ID:****"
See Using Java manual...
It is true indeed that if not used VERY CAREFULLY the JMS selector will have a VERY significant impact on performance.
 |
|
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
|
|
|
|