|
RSS Feed - WebSphere MQ Support
|
RSS Feed - Message Broker Support
|
 |
|
Reading certain kind of messages, but not the others |
« View previous topic :: View next topic » |
Author |
Message
|
egoine |
Posted: Thu Aug 08, 2002 4:42 am Post subject: Reading certain kind of messages, but not the others |
|
|
Newbie
Joined: 16 Apr 2002 Posts: 6 Location: Montreal
|
Hi,
we have this situation where we want to be able to read only a certain category of messages from a Queue. That is, the queue receives messages of both type 'A' and type 'B'. Usually we want to get both kind of messages but in some situations, only messages of type 'B' should be read and processed. Type 'A' messages are persistant. They should just stay in the queue until we are ready to start processing them. So for a while we would only read and process type 'B' messages, then go back to processing both types.
From reading the documentation, I tought I could do that with groupid. All messages of type 'A' would get a certain groupid and messages of type 'B' would get another one. Then I would use a selector on the groupid to be able to get only type 'B' messages.
Now, re-reading doc and examples, I think groupid might not be the correct way of doing this. It appears to be designed to send messages in group, not to categorize them.
On the sending side, I have Java and I'm doing this :
Code: |
BytesMessage inputMsg = session.createBytesMessage();
//set the groupid so the AS400 receiving the message knows its role
//regarding this message and can decide what to do with it.
if ( blabla ) {
inputMsg.setStringProperty(JMS_GROUPID_PROPERTY,GROUPID_MSG_TYPE_B);
} else {
inputMsg.setStringProperty(JMS_GROUPID_PROPERTY,GROUPID_MSG_TYPE_A);
}
//send the message....
|
On the receiving side, (AS/400 with RPG) we have difficulties filtering the messages using a selector or reading the message at all. It looks like the data has been offset by a 72 bytes "header" containing the groupid. Now I have to say I'm not the one coding the RPG side and I'm totally incompetent when it comes to RPG.
Using the explorer, I can see messages in the queue, and I can see they have a groupid set (the encoding makes it hard to read but I can see it's there).
Is this approach valid at all? Is there a better way of doing this type of thing? I would like a solution where I don't have to add queues etc. to the system.
Can somebody point me in the right direction for this to work?
Thanks a lot. |
|
Back to top |
|
 |
GMcCarthy |
Posted: Thu Aug 08, 2002 10:14 am Post subject: |
|
|
 Centurion
Joined: 06 Nov 2001 Posts: 113 Location: Melville NY
|
Would setting 2 specific correlation ids work for you in this case? _________________ Regards,
Gina
IBM Certified MQSeries Specialist |
|
Back to top |
|
 |
bduncan |
Posted: Thu Aug 08, 2002 10:56 am Post subject: |
|
|
Padawan
Joined: 11 Apr 2001 Posts: 1554 Location: Silicon Valley
|
You are correct, GroupId is not used for "categorizing" messages, only putting them into logical groups.
As far as an alternative, the preferred way of doing this the MsgType parameter.
The reason you wouldn't want to use the CorrelId is because now you've basically prevented yourself from ever using a request/reply scheme based on CorrelId in addition to categorizing the messages.
You'll find that MsgType allows you to set an integer value, so type 'A' might have 1000, and type 'B' might have 2000, or something like that... _________________ Brandon Duncan
IBM Certified MQSeries Specialist
MQSeries.net forum moderator |
|
Back to top |
|
 |
GMcCarthy |
Posted: Thu Aug 08, 2002 11:03 am Post subject: |
|
|
 Centurion
Joined: 06 Nov 2001 Posts: 113 Location: Melville NY
|
Brandon,
Thanks for your response. I wasn't aware we can use application defined MsgType. Cool.... _________________ Regards,
Gina
IBM Certified MQSeries Specialist |
|
Back to top |
|
 |
egoine |
Posted: Thu Aug 08, 2002 11:38 am Post subject: How do I read the messages of a certain message type? |
|
|
Newbie
Joined: 16 Apr 2002 Posts: 6 Location: Montreal
|
Thanks a lot for the answers.
I cannot use the correl id, it's already used in order to correllate response with requests.
Looking into the documentation, there are 2 things I don't understand relating to msg type:
1-On the receiving end, how do I read message from category 'A' only?
If I have msgtype set to 1000 for category 'A' as suggested, do I have to browse the queue to manually find each message of that type?
From what I read here http://www-3.ibm.com/software/ts/mqseries/library/manualsa/csqzal05/csqzal052d.htm, there is no way I can ask for the next message with a given type.
It is my understanding that browsing the queue to find the messages will slow down the system.
Would creating a special receiver with a selector like asking for msgtype=1000 be a possibility?
2 (minor point)-There seems to be 2 ways to set the msg type in Java (via JMS):
and
Code: |
setIntProperty("JMS_IBM_MsgType", 1000)
|
Does these 2 do the same thing? |
|
Back to top |
|
 |
bduncan |
Posted: Thu Aug 08, 2002 12:43 pm Post subject: |
|
|
Padawan
Joined: 11 Apr 2001 Posts: 1554 Location: Silicon Valley
|
You are right, you can't match against MsgType. I completely forgot about that. So yes, to use MsgType you'd have to browse the queue, capture the MsgId of a message with the proper MsgType, and then MQGET based on that MsgId. Not the most efficient way of doing things...
In this case, I would recommend concatenating your "category" value on the end of either the MsgId or CorrelId of your messages. Of course, doing this will preclude you from letting the queue manager generate these parameters for you automatically.
In the end, I'd ask you this question: is it at all possible for you to redesign your message flows such that all messages of type "A" end up on queue "A" and all messages of type "B" end up on queue "B"? This removes the need for all this matching, and since it sounds like a different application processes each type of message, it's simply a more elegant system to have each application reading from a queue that contains only the type of messages that application desires... _________________ Brandon Duncan
IBM Certified MQSeries Specialist
MQSeries.net forum moderator |
|
Back to top |
|
 |
egoine |
Posted: Thu Aug 08, 2002 1:47 pm Post subject: |
|
|
Newbie
Joined: 16 Apr 2002 Posts: 6 Location: Montreal
|
Quote: |
In this case, I would recommend concatenating your "category" value on the end of either the MsgId or CorrelId of your messages. Of course, doing this will preclude you from letting the queue manager generate these parameters for you automatically.
|
That's exactly what we've chosen to try now. Initial experiences shows it works. (We are using the correl id. The msg id is let for the qm to generate. Since we already handle the correl id ourselves, we're not loosing that much).
Regarding the redesign of the queues: well, I certainly think it a more robust and clean approach to all of this, but I'v been explicitely told to find a low risk, low change impact solution reusing the current queing scheme. That explains why I'm trying to do this.
Thanks for the help. |
|
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
|
|
|
|