ASG
IBM
Zystems
Cressida
Icon
Netflexity
 
  MQSeries.net
Search  Search       Tech Exchange      Education      Certifications      Library      Info Center      SupportPacs      LinkedIn  Search  Search                                                                   FAQ  FAQ   Usergroups  Usergroups
 
Register  ::  Log in Log in to check your private messages
 
RSS Feed - WebSphere MQ Support RSS Feed - Message Broker Support

MQSeries.net Forum Index » IBM MQ Java / JMS » MQ Message coming out of sequence

Post new topic  Reply to topic
 MQ Message coming out of sequence « View previous topic :: View next topic » 
Author Message
cse.gokul
PostPosted: Wed Jul 22, 2015 7:14 am    Post subject: MQ Message coming out of sequence Reply with quote

Newbie

Joined: 22 Jul 2015
Posts: 5

My J2EE application has 2 QCFs for load balancing and for failover. The J2EE app puts message 1, does some processing and puts message 2 to queues via QCF1/QCF2. Both QCFs connects to the its queue managers and alias queues. And then queues messages are routed to a common single local queue which another app consumes.

In some cases, message 2 is coming before message 1 in the common local queue. If I check the messages in the queue, I can see the timestamp and identify that message 2 has sequence number before message 1.

Consumer is dependent on the sequence of the message and it is failing due to this.

Could you suggest what can be done at MQ end or J2EE app to maintain the sequence?
Back to top
View user's profile Send private message
fjb_saper
PostPosted: Wed Jul 22, 2015 7:21 am    Post subject: Reply with quote

Grand High Poobah

Joined: 18 Nov 2003
Posts: 20696
Location: LI,NY

Have you tried putting both messages in a group?
_________________
MQ & Broker admin
Back to top
View user's profile Send private message Send e-mail
cse.gokul
PostPosted: Wed Jul 22, 2015 7:26 am    Post subject: Reply with quote

Newbie

Joined: 22 Jul 2015
Posts: 5

I cannot group it as application can fail during the processing between the two put. So that atleast 1 put is done in case of any failures.
Back to top
View user's profile Send private message
fjb_saper
PostPosted: Wed Jul 22, 2015 7:30 am    Post subject: Reply with quote

Grand High Poobah

Joined: 18 Nov 2003
Posts: 20696
Location: LI,NY

cse.gokul wrote:
I cannot group it as application can fail during the processing between the two put. So that atleast 1 put is done in case of any failures.

Consider sending them in a unit of work. i.e. both messages or none.

[moving to Java forum]
_________________
MQ & Broker admin
Back to top
View user's profile Send private message Send e-mail
Vitor
PostPosted: Wed Jul 22, 2015 7:45 am    Post subject: Re: MQ Message coming out of sequence Reply with quote

Grand High Poobah

Joined: 11 Nov 2005
Posts: 26093
Location: Texas, USA

cse.gokul wrote:
Consumer is dependent on the sequence of the message and it is failing due to this.


And this is one reason why message affinity (the processing of a message being dependent on the message received before or after it) is a bad practice design.

Another is that it doesn't scale. The consumer can only ever have one reading thread as there's no way to assure that message 2 will be picked up by the same thread that read message 1.
_________________
Honesty is the best policy.
Insanity is the best defence.
Back to top
View user's profile Send private message
Vitor
PostPosted: Wed Jul 22, 2015 7:51 am    Post subject: Reply with quote

Grand High Poobah

Joined: 11 Nov 2005
Posts: 26093
Location: Texas, USA

fjb_saper wrote:
Consider sending them in a unit of work. i.e. both messages or none.


Assuming that message 2 isn't dependent on message 3 in the same way message 2 is on message 1. Also the OP seems to indicate that message 1 is required even if there's a failure producing message 2.

Another answer, which is perhaps more general, is to only use a single QCF. If your consumer can't load balance, why should the producer? A single threaded producer ensures message sequence.
_________________
Honesty is the best policy.
Insanity is the best defence.
Back to top
View user's profile Send private message
mqjeff
PostPosted: Wed Jul 22, 2015 7:57 am    Post subject: Reply with quote

Grand Master

Joined: 25 Jun 2008
Posts: 17447

Vitor wrote:
A single threaded producer ensures message sequence.

Assuming a single route through the queue manager network, and a single destination.
Back to top
View user's profile Send private message
cse.gokul
PostPosted: Wed Jul 22, 2015 7:59 am    Post subject: Reply with quote

Newbie

Joined: 22 Jul 2015
Posts: 5

Thanks for the inputs.
Back to top
View user's profile Send private message
Vitor
PostPosted: Wed Jul 22, 2015 8:56 am    Post subject: Reply with quote

Grand High Poobah

Joined: 11 Nov 2005
Posts: 26093
Location: Texas, USA

mqjeff wrote:
Vitor wrote:
A single threaded producer ensures message sequence.

Assuming a single route through the queue manager network, and a single destination.


Assuming that.
_________________
Honesty is the best policy.
Insanity is the best defence.
Back to top
View user's profile Send private message
fjb_saper
PostPosted: Wed Jul 22, 2015 11:33 am    Post subject: Reply with quote

Grand High Poobah

Joined: 18 Nov 2003
Posts: 20696
Location: LI,NY

Vitor wrote:
mqjeff wrote:
Vitor wrote:
A single threaded producer ensures message sequence.

Assuming a single route through the queue manager network, and a single destination.


Assuming that.

Assuming on top of that that the messages in the same group have all the same priority, or that all queues involved, including xmit queues are set to FIFO for msg delivery sequence... (default is priority)
_________________
MQ & Broker admin
Back to top
View user's profile Send private message Send e-mail
gbaddeley
PostPosted: Wed Jul 22, 2015 5:45 pm    Post subject: Re: MQ Message coming out of sequence Reply with quote

Jedi

Joined: 25 Mar 2003
Posts: 2492
Location: Melbourne, Australia

cse.gokul wrote:
Could you suggest what can be done at MQ end or J2EE app to maintain the sequence?

MQ does not guarantee message sequence, except in very specific circumstances. Do not design apps to rely on this!
Sequencing should be built into the consuming app design to perform message order marshalling, eg. use a database to store messages until all messages in the required sequence have arrived. It also needs to cater for missing messages.
Another approach is to bundle all the sequenced data into a single message or a message "group".
_________________
Glenn
Back to top
View user's profile Send private message
cse.gokul
PostPosted: Thu Jul 23, 2015 7:36 am    Post subject: Reply with quote

Newbie

Joined: 22 Jul 2015
Posts: 5

we finalized to change the consumer to remove dependency of the sequence. Thanks for the inputs again.
Back to top
View user's profile Send private message
apatnaik14
PostPosted: Wed Aug 12, 2015 1:17 pm    Post subject: Reply with quote

Newbie

Joined: 11 Aug 2015
Posts: 8

I feel like the dependency was in place to identify and map the request and response pair or even just the request messages, since you made it clear above that request 2 is not dependent on the output of request 1.

In that case, you can just use the correlationId to identify the request and responses, or even just the request messages.

Hope the idea was of some help!

Regards,
A
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic  Reply to topic Page 1 of 1

MQSeries.net Forum Index » IBM MQ Java / JMS » MQ Message coming out of sequence
Jump to:  



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
Protected by Anti-Spam ACP
 
 


Theme by Dustin Baccetti
Powered by phpBB © 2001, 2002 phpBB Group

Copyright © MQSeries.net. All rights reserved.