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 » General IBM MQ Support » using MQ as events broker

Post new topic  Reply to topic
 using MQ as events broker « View previous topic :: View next topic » 
Author Message
lenar
PostPosted: Tue Sep 13, 2011 2:25 am    Post subject: using MQ as events broker Reply with quote

Newbie

Joined: 13 Sep 2011
Posts: 3

Hi

I want to use MQ queue as synchronization of events from parallel processes.

I need something like this:

application ProducerA put message DoneA to queue with transaction TID,
application ProducerB put message DoneB to queue with transaction TID,
application ProducerC put message DoneC to queue with transaction TID,

application Consumer wait until there are three messages in queue DoneA,DoneB,DoneC with the same TID and then get these messages in UOW and communicate: all work with TID is done.

Producer X produce messages DoneX with various TID.

Is it possible to be done by using groups? For example first ProducerC put message with groupID=TID , sequence=3 and flag: LAST_MSG_IN_GROUP, next ProducerA put message with groupID=TID , sequence=1, next ProducerB put message with groupID=TID , sequence=2.
Consumer wait with flag: ALL_MSG_IN_GROUP.

I set flag LAST_MSG_IN_GROUP in ProducerC even if ProducerC first finishes his work and first put message to queue - he does not know about it.
Back to top
View user's profile Send private message
Vitor
PostPosted: Tue Sep 13, 2011 4:19 am    Post subject: Re: using MQ as events broker Reply with quote

Grand High Poobah

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

lenar wrote:
I set flag LAST_MSG_IN_GROUP in ProducerC even if ProducerC first finishes his work and first put message to queue - he does not know about it.


This strikes me as a bit of a problem - if C signals the group is complete before A & B have finished it's going to be a bit bad.

IHMO you're better off having the consumer application read the individual messages as they arrive, store them (database?) and apply whatever logic is necessary to decide it's got all the messages for a given transaction. This would also cater for scenarios where A produces 2 messages for a TID giving 4 messages not 3.

If you had WMB (and you've given no indication that you have) then a Collector node would do this for you out of the box.
_________________
Honesty is the best policy.
Insanity is the best defence.
Back to top
View user's profile Send private message
lenar
PostPosted: Tue Sep 13, 2011 5:42 am    Post subject: Reply with quote

Newbie

Joined: 13 Sep 2011
Posts: 3

Ok, so when someone put message with flag LAST_MSG_IN_GROUP QueueManagers decide that the group is full.

Another option is to decide that group is full when all seq numbers from 1 to seq number with LAST_MSG_IN_GROUP are filled, so if you put MSG: seq 1, MSG: seg 3 LAST_MSG_IN_GROUP then queue manager will wait until MSG: seq 2 arrive - but it is not like that?
Back to top
View user's profile Send private message
Vitor
PostPosted: Tue Sep 13, 2011 5:55 am    Post subject: Reply with quote

Grand High Poobah

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

lenar wrote:
Another option is to decide that group is full when all seq numbers from 1 to seq number with LAST_MSG_IN_GROUP are filled, so if you put MSG: seq 1, MSG: seg 3 LAST_MSG_IN_GROUP then queue manager will wait until MSG: seq 2 arrive - but it is not like that?


Well it's like that if you specifically write application code to make that happen but the queue manager won't enforce it. It's a sequence number, not a serial number; you can have a group with 1,2,5,6,12,56 if you want.

And note that the queue manager won't even enforce the sequence unless you ask it.

If you do write application code it's going to be tricky, inefficient and will eat CPU. That's why I suggested a database.
_________________
Honesty is the best policy.
Insanity is the best defence.
Back to top
View user's profile Send private message
bruce2359
PostPosted: Tue Sep 13, 2011 5:57 am    Post subject: Reply with quote

Poobah

Joined: 05 Jan 2008
Posts: 9469
Location: US: west coast, almost. Otherwise, enroute.

The LAST_MSG_IN_GROUP flag is set by the programmer that creates the message. The purpose is to tell the consuming application that there are no more messages in the group. The qmgr doesn't know, and doesn't care about this - and most other fields in the MQMD.
_________________
I like deadlines. I like to wave as they pass by.
ב''ה
Lex Orandi, Lex Credendi, Lex Vivendi. As we Worship, So we Believe, So we Live.
Back to top
View user's profile Send private message
fjb_saper
PostPosted: Tue Sep 13, 2011 5:59 am    Post subject: Reply with quote

Grand High Poobah

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

You best shot is to log the messages in a DB.
Have an index on unprocessed messages and work on messages with key having count(*) = total expected # of messages.

There is no good solution as there is no time limit as to when all messages will be available...
_________________
MQ & Broker admin
Back to top
View user's profile Send private message Send e-mail
mqjeff
PostPosted: Tue Sep 13, 2011 6:25 am    Post subject: Reply with quote

Grand Master

Joined: 25 Jun 2008
Posts: 17447

Or at least don't try to use grouping this way.

just have the Consumer wait until it's received the correct number of DoneX messages.
Back to top
View user's profile Send private message
lenar
PostPosted: Tue Sep 13, 2011 6:37 am    Post subject: Reply with quote

Newbie

Joined: 13 Sep 2011
Posts: 3

ok, thanks
Back to top
View user's profile Send private message
gbaddeley
PostPosted: Tue Sep 13, 2011 5:25 pm    Post subject: Re: using MQ as events broker Reply with quote

Jedi Knight

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

Vitor wrote:
IHMO you're better off having the consumer application read the individual messages as they arrive, store them (database?) and apply whatever logic is necessary to decide it's got all the messages for a given transaction. This would also cater for scenarios where A produces 2 messages for a TID giving 4 messages not 3.

If you had WMB (and you've given no indication that you have) then a Collector node would do this for you out of the box.


I agree with Vitor's suggestions. MQ is designed for asynchronous messaging but the OP is trying to implement a synchronous messaging paradigm with message affinity from independent sources. Its better to implement this design requirement in the application rather than trying to use MQ features (message grouping) which are not designed for this particular use case.
_________________
Glenn
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 » General IBM MQ Support » using MQ as events broker
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.