Author |
Message
|
mqfond |
Posted: Mon Mar 28, 2005 12:30 pm Post subject: Message Sequence |
|
|
Novice
Joined: 28 Mar 2005 Posts: 20
|
We are sending messages to the remote machine and that machine needs the mesages in certain order, orelse it gives error. They are planning to write a java program on the remote box to do that, maybe check to see that all required messages come through before it commits. What do yo u think would be the best approach to write that in java??? |
|
Back to top |
|
 |
fjb_saper |
Posted: Mon Mar 28, 2005 2:05 pm Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
Why not put the whole transaction into a single message ?
 |
|
Back to top |
|
 |
hopsala |
Posted: Mon Mar 28, 2005 2:34 pm Post subject: |
|
|
 Guardian
Joined: 24 Sep 2004 Posts: 960
|
MQSeries has build in structures and options in MQI (or the Java MQ API) to help you do this more easily.
in the MQMD Structures there are fields called MessageGroup and LogicalMessageNumber (may be different names for different API's). What you do is give each transaction a group number, say 1, and then enumerate each message belonging to that transaction, so that you have the first is message 1 in group 1, the second msg 2 in grp 1 etc. In the last you mark a flag saying this is the last message in the group. Then you move on to the next transaction, create a group 2 and so on and so forth...
Now, this Does Not make sure that the message arrive to the queue in the right order, but if in the receiving application you choose MQGMO= MQGMO_LOGICAL_ORDER you will get the in order, so if for example you have only msg with grp=1 num=2 in the queue, the application will wait until msg grp=1 num=1 comes through and gets it.
(You will probably also want to put all messages in group as one transaction, meaning you do not MQCMIT them until they are all MQPUT to the queue by the sending application...)
See details of this in MQ Application Guide chapter 10 section 2 "The order in which messages are retrieved from a queue".
Luck! |
|
Back to top |
|
 |
mqfond |
Posted: Mon Mar 28, 2005 4:44 pm Post subject: |
|
|
Novice
Joined: 28 Mar 2005 Posts: 20
|
Thanks guys. I will definitely try your suggestions. |
|
Back to top |
|
 |
mqfond |
Posted: Tue Mar 29, 2005 8:16 am Post subject: |
|
|
Novice
Joined: 28 Mar 2005 Posts: 20
|
One more doubt i got about grouping and sequencing the messages by hopsala, we are using two queue managers for the load balancing. I guess we can't get that sequencing as the messages might be generated from different queue managers??? am i right?? |
|
Back to top |
|
 |
bower5932 |
Posted: Tue Mar 29, 2005 9:05 am Post subject: |
|
|
 Jedi Knight
Joined: 27 Aug 2001 Posts: 3023 Location: Dallas, TX, USA
|
You might need to look into the BIND_ON_OPEN option on your MQOPEN to make sure that you get bound to a specific queue (queue manager) for all of the messages that you put. |
|
Back to top |
|
 |
Keka |
Posted: Tue Mar 29, 2005 11:51 am Post subject: |
|
|
Voyager
Joined: 28 Dec 2002 Posts: 96
|
You said you are using two queue managers for load balancing, so the assumption here is you are using Clustering. If you are bind on open from the application side will make all the messages go in to the same queue manager and same queue instance. you also have to use logical grouping under symcpointing from the application side.
Onthe server side again as suggested you have to use logical reading with a get under sync point. _________________ Keka |
|
Back to top |
|
 |
mqfond |
Posted: Tue Mar 29, 2005 11:56 am Post subject: |
|
|
Novice
Joined: 28 Mar 2005 Posts: 20
|
Hey thanks for the info. Yes we are using cluster. I will definitely take your consideration. |
|
Back to top |
|
 |
|