wood burning stoves 2.0*
The moose likes EJB and other Java EE Technologies and the fly likes Seq of messages in a Pub-Sub arch... is FIFO gauranteed? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "Seq of messages in a Pub-Sub arch... is FIFO gauranteed?" Watch "Seq of messages in a Pub-Sub arch... is FIFO gauranteed?" New topic
Author

Seq of messages in a Pub-Sub arch... is FIFO gauranteed?

Jeevan Sunkersett
Ranch Hand

Joined: Jul 03, 2007
Posts: 75
Hi,

In our JMS based architecture 2 applications are in a Pub-Sub mode.

For instance
The logs, show the PUBlisher appliation, publishing out 7 messages ... (6 are tagged as IN-process and the 7th COMPLETED)

but
the logs on the SUBcriber side, do not process those 7 messages in the exact same sequence.

On the subscriber side the messages are received in the onMessage() method of the listener
our logic is dependant on the order in which they are processed.
meaning; the 6 IN-progress messages must be processed, before the final 7th COMPLETED message.

The logs show, the first 3/4 messages are processed in sequence and then
suddenly the the final 7th COMPLETED message is received in the onMessage() before the 5h/ 6th, screwing up the logic and further flow.

However if this is executed in DEBUG mode, everything is a bit slow and proceeds smoothly

any cluues?

~g1

PS: We are using Ative MQ as our JMS provider,
The publisher publishes to a Virtual-Topic
and subscriber consumes from a Consumer queue created on that VT.

We are NOT using EJB's.
Jeevan Sunkersett
Ranch Hand

Joined: Jul 03, 2007
Posts: 75
added to the above,

we can see from the logs that some messages published by the PUBLISHER are in a rapid sequence .... even upto Milli-second accuracy.

Deepak Pant
Ranch Hand

Joined: Feb 13, 2004
Posts: 443
1. I have worked on WebLogic and WebSphere JMS implementations and I am not aware of such FIFO guarantee.

2. Even if there was a guarantee and onMessage() gets called you still cannot guarantee that it will finish before other onMessage() methods that get called afterwards.

3. If FIFO sequence is very important then you can think of throttling down the number of consumers who are listening to the messages. This can be done in Weblogic via deployment descriptor and in WebSphere via admin console option for the destination.
Jeevan Sunkersett
Ranch Hand

Joined: Jul 03, 2007
Posts: 75
Deepak,

I re-phrase .... instead of "gauranteed", can it be like .....can FIFO be expected ?

I am contemplating ... to set the JMSPrority in the header of the outgoig messages on the publisher side so that the messages are priotorized.


http://community.jboss.org/wiki/JMSPriority
Ordering is done first on priority, then on message ID (which gets incremented per message sent). Assuming priorities for a set of messages is the same,
and you are sending a message using a single thread/session, they will be returned in the same relative order when received by a single thread consumer.


akin to the way we can priotorize Load-on-startup servlets by assigning a 'weight' in the web.xml.

your inputs please.

~g1
Deepak Pant
Ranch Hand

Joined: Feb 13, 2004
Posts: 443
Yes I think using this approach will ensure FIFO ordering for all messages generated by a message producer (or client or session).

So for example:

1. FIFO order will be maintained if 10 messages are generated by a client/session.

2. FIFO order will not be maintained across two clients/sessions that are generating/producing 10 messages each. It will be maintained within each of the 10 messages. But not across both the clients.
Azrael Noor
Ranch Hand

Joined: Jul 29, 2010
Posts: 378
no we are not able to acheive through said mechanisam too.

Even i am applying Durable Subscriptions, where i am not able to get all messages in order.

I have made my own classes to solve this purpose. and i will not gonna share with you guys.

Regards
Azrael Noor
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Seq of messages in a Pub-Sub arch... is FIFO gauranteed?
 
Similar Threads
A Beginner Question About JMS
Putting JMS Queues into a database
JMS:Difference between CLIENT and AUTO_ACKNOWLEDGE modes
Observer Example
JMS Topic Multiple Subscribers Question!!!