How are messages delivered to multiple consumers on one queue?

View: New views
2 Messages — Rating Filter:   Alert me  

How are messages delivered to multiple consumers on one queue?

by Dirk Grosskopf :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

All

I'm currently trying to tune an system that was implemented a while ago. This consists of multi threaded consumers, that creates consumer connections to multiple queues. The onMessage() call back method implementation places the the message onto a internal bounded memory queue. If the internal queue size reaches a maximum size, the onMessage() call is deferred until a worker thread has consumed a message from the internal queue.

My questions:
1) How are messages delivered to multiple consumer connections that registers message listeners? I assume it is round robin, isn't it?

2) What happens when the onMessage() call is deferred and another message arrives.

Thanks Dirk

Re: How are messages delivered to multiple consumers on one queue?

by IIT Software :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

1) How are messages delivered to multiple consumer connections that registers message listeners? I assume it is round robin, isn't it?
Yes, but based on the smqp-consumer-cache-size (defined in the connection factory, default 500). Say, there are 2000 messages in the queue and you have 2 consumers with the same consuming speed. C#1 gets 1-500, C#2 501-1000, C#1 1001-1500, C#2 1501-2000.

The smqp-consumer-cache-size is very important for throughput and should stay at the default, except there is a good reason to change it.

Multiple consumers on a single queue creates more contention on the queue and will influence performance. A much better alternative is to use so-called Local Clustering.

2) What happens when the onMessage() call is deferred and another message arrives.
The session delivery thread is blocked. There are 10 threads in client-side session thread pool. So if you have multiple sessions, all waiting for onMessage to finish, this pool might run out of threads.