Author |
Message
|
angka |
Posted: Thu Dec 28, 2006 6:46 pm Post subject: MQ gurantee first send first receive?? |
|
|
Chevalier
Joined: 20 Sep 2005 Posts: 406
|
Hi,
Does MQ gurantee that the first message sent will be the first message received from the same source going to the same destination?
Thanks. |
|
Back to top |
|
 |
pathipati |
Posted: Thu Dec 28, 2006 6:50 pm Post subject: |
|
|
Master
Joined: 03 Mar 2006 Posts: 296
|
|
Back to top |
|
 |
angka |
Posted: Thu Dec 28, 2006 7:03 pm Post subject: |
|
|
Chevalier
Joined: 20 Sep 2005 Posts: 406
|
Hi,
What you mean by tt? You mean it may not be in sequence due to TCP/IP?? |
|
Back to top |
|
 |
pathipati |
Posted: Thu Dec 28, 2006 7:06 pm Post subject: |
|
|
Master
Joined: 03 Mar 2006 Posts: 296
|
Yes, and it may be because of Priority. |
|
Back to top |
|
 |
angka |
Posted: Thu Dec 28, 2006 7:18 pm Post subject: |
|
|
Chevalier
Joined: 20 Sep 2005 Posts: 406
|
Hi,
But shldn't TCP/IP in sequence? Cos it is connection dependent. for my system message priority is not set.. thanks |
|
Back to top |
|
 |
pathipati |
Posted: Thu Dec 28, 2006 7:49 pm Post subject: |
|
|
Master
Joined: 03 Mar 2006 Posts: 296
|
If you are using TCP/IP, and messages with no priority settings and no persistance then Probably MQ will guarantee FIFO. |
|
Back to top |
|
 |
Vitor |
Posted: Thu Dec 28, 2006 11:41 pm Post subject: |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
pathipati wrote: |
Probably MQ will guarantee FIFO. |
"Probably" is not a really good guarantee!
And no, MQ does not guarantee FIFO delivery. In the scenario you're describing where sender & receiver are one-to-one then "very probably" is as good as you're likely to get. If that's good enough for your process is a decision only you can make. _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
angka |
Posted: Fri Dec 29, 2006 12:22 am Post subject: |
|
|
Chevalier
Joined: 20 Sep 2005 Posts: 406
|
Hi,
No the receiver cannot receive the message out of sequence.. is it possible to make it FIFO delivery? thanks |
|
Back to top |
|
 |
Vitor |
Posted: Fri Dec 29, 2006 12:31 am Post subject: |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
angka wrote: |
Hi,
No the receiver cannot receive the message out of sequence.. is it possible to make it FIFO delivery? thanks |
Because MQ treats each message as a separate item of work it's not possible to enforce message sequence. You can do tricks to make it more likely, but as the old saw goes "MQ assures delivery, it does not guarantee it".
Having a message dependant on the message imediately before it or after it is known as message affinity. Do a search in the forum for that term and you may find something of use. Message affinity is generally held to be anti-pattern and a bad thing, for reasons the search will throw up. _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
jsware |
Posted: Fri Dec 29, 2006 12:32 am Post subject: |
|
|
 Chevalier
Joined: 17 May 2001 Posts: 455
|
angka wrote: |
Hi,
No the receiver cannot receive the message out of sequence.. is it possible to make it FIFO delivery? thanks |
You can have messages delivered in order via a number of mechanisms:
1. Chain them via the CorrelID. Have the "first message" use a fixed correl ID (e.g. all 0s) and each next message has the msgid of the previous message. Get the first, then use the msg id on a match option for the next message's correl id.
2. You might be able to use the msg seq number and match on sequence number. I have not tried this.
3. Follow the instructions under MQPUT usage notes item 2 very closely. Some of these will stop your application scaling well.
Alternatively change your design so that out of sequence messages are handled gracefully. Always the best option IMHO. _________________ Regards
John
The pain of low quaility far outlasts the joy of low price. |
|
Back to top |
|
 |
Vitor |
Posted: Fri Dec 29, 2006 12:39 am Post subject: |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
scottj2512 wrote: |
You can have messages delivered in order via a number of mechanisms:
1. Chain them via the CorrelID. Have the "first message" use a fixed correl ID (e.g. all 0s) and each next message has the msgid of the previous message. Get the first, then use the msg id on a match option for the next message's correl id. |
Pedantically, that doesn't ensure delivery by MQ is in sequence but that the application receives messages in sequence. While this is the correct place to put the logic, you might be better advised to read the messages off as they arrive and use a sequence number added to the message body. Saves messages getting stuck on the queue if the chain breaks.
And of course requires code at sender & reciever whatever method you use. I think angka is attempting to do this within MQ.
scottj2512 wrote: |
2. You might be able to use the msg seq number and match on sequence number. I have not tried this.
|
I would be surprised to discover this works.
scottj2512 wrote: |
3. Follow the instructions under MQPUT usage notes item 2 very closely. Some of these will stop your application scaling well. |
Applications with message affinity seldom scale. It's one of the reasons it's disliked.
scottj2512 wrote: |
Alternatively change your design so that out of sequence messages are handled gracefully. Always the best option IMHO. |
Gets my vote!  _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
angka |
Posted: Fri Dec 29, 2006 12:58 am Post subject: |
|
|
Chevalier
Joined: 20 Sep 2005 Posts: 406
|
Hi,
Thanks for the prompt reply. =) I will look into those alternative. btw channel commit the transaction of the messages after the number stated in the channel Batch size attribute is reached, doesn't it check for the sequence? |
|
Back to top |
|
 |
Vitor |
Posted: Fri Dec 29, 2006 1:07 am Post subject: |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
angka wrote: |
doesn't it check for the sequence? |
No.
What would it do if it found a message missing from the sequence due to application failure? Or a duplicate? Fail? Dump them to the DLQ? Plus the additional overhead that would add to the MCA. It's not the job of MQ as built to determine these things. As scottj2512 points out, message sequence is an application requirement not an MQ one. _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
Vitor |
Posted: Fri Dec 29, 2006 1:13 am Post subject: |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
I hesitate to mention this, but...
The other thing you could do is build a channel exit to check sequence. Exits are not to be attempted lightly and if improperly written can cause all sorts of problems. Even if it worked, you'd have all the problems I talk about in the previous post - what to do if a message is out of sequence? Also remember that any message sent across the channel would pass through the exit, so if another class of message without a sequence requirement was added the exit would need to recognise this or you'd need to define a new channel.
I mention it because it is an option, but one I urge you to dismiss as a possibility. It's a first class ticket to pain & misery.
The far better option is to remove the necessity for sequencing within the application. _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
angka |
Posted: Fri Dec 29, 2006 1:22 am Post subject: |
|
|
Chevalier
Joined: 20 Sep 2005 Posts: 406
|
Hi,
Thanks for the reply.. Think i will let the application do it.. Happy New Year..
Cheers |
|
Back to top |
|
 |
|