Question

I want to log using the OpenMQ from GlassFish. I'm thinking my components can put messages on this queue and if only a single mdb consumes from it, I should be able to receive all messages in the order that they were enqueued. Will this work and how can the message order be kept?

Just for reference there was a slide in a presentation that originally led me to believe JMS provided an order, apparently it is misleading.

Transcript of Slide 8:

What Is JMS ? • A Java-based api for Message Oriented Middleware. • It use the following concepts (among others) > Message Order is guaranteed > Level of reliability is determined when the message is sent > Transactions (grouping of messages to be sent or produced together) are supported > Format of the message is defined by the producer > Provides two styles of message delivery (point-to-point and publish-subscribe) Copyright Sun Microsystems Inc. All Rights Reserved. [8]

http://www.slideshare.net/alexismp/openmq-aquarium-paris-presentation

These answers below inform that JMS structures do not guarantee an order. But I'm thinking if I just have one MDB, that is a singleton using container concurrency, then I can at least enjoy an enqueue order.

See:

Was it helpful?

Solution

I wouldn't worry about ensuring order on the Queue itself. Just include a timestamp field in your message payload and sort on that after-the-fact. This only becomes a problem when the extra data is unacceptable under extremely high-traffic conditions, but in those cases, it might make sense to revert to local logging temporarily anyway.

Having the additional field also ensures that if a component loses its connection to the Queue, then messages that were intended for delivery an hour prior still have the correct time and "order" when they do make it to the consuming MDB.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top