0

I need to consume from a Q, and stamp a sequence key on each message to indicate the ordering. i.e. the consumption needs to be sequential. From performance/throughput point of view, would I be better off using a blocking receive() method, or an async listener with a single-threaded configuration on the onMessage() method?

Thanks.

wqt
  • 1
  • 1

1 Answers1

1

There are many aspects that will affect the performance and throughput; in pure JMS terms it's not really possible to state that the sync or async model of getting messages will be any less or more efficient. It will depend on a large number of factors from how the application is written, other resources it's using, implementation of your chosen messaging provider and other factors such as machine performance and configuration of both client and server machines.

This discussion, Single vs Multi-threaded JMS Producer, covered some of these topics.

To the sequence, if you are single threaded, with a single session the JMS specification gives some assurances on message ordering; best to review the spec to see if it matches your overall requirements.

Often people will insert an application sequence number at message production time; the consumer can therefore check they are getting the correct message in order. Adding a sequence number at consumption time won't specifically help that consumer.

Keep in mind that the stricter the requirement for messaging ordering the more restrictive the overall architecture gets and the harder it is to implement horizontal scalabilty.

Community
  • 1
  • 1
Calanais
  • 1,541
  • 9
  • 10
  • Thanks for the reply. I also suspected "hard to say" was the answer. As for the message ordering, I wouldn't have to do anything sequential on the consumer side if the Q producer puts in the sequence keys - but they won't. I would go further to say it is an impedance mismatch between messaging and ordering, just like that of OR mapping. – wqt Oct 09 '14 at 16:30
  • On option might be for the consumer to look at the timestamps of the messages; this can be disabled however and it does depend on how much you trust the times to be accurate. But it might give the consumer and indication of something that is out of sequence. – Calanais Oct 10 '14 at 08:19