开发者

Limiting JMS Destination Instances

Is it possible to limit the number of JMS receiver instances to a single instance? I.e. only process a single message from a queue at any one time?

The reason I开发者_Go百科 ask is because I have a fairly intensive render type process to run for each message (potentially many thousands). I'd like to limit the execution of this code to a single instance at a time.

My application server is JBoss AS 6.0


You can configure the queue listener pool to have a single thread, so no more than one listener is handling requests, but this makes no sense to me.

The right answer is to tune the size of the thread pool to balance performance with memory requirements.

Many thousands? Per second, per minute, per hour? The rate at which they arrive, and the time each task takes, are both crucial. How much time, memory, CPU per request? Make sure you configure your queue to handle what could be a rather large backlog.

UPDATE: If ten messages arrive per second, and it takes 10 seconds for a single listener to process a message, then you'll need 101 listener threads to be able to keep up. (10 messages/second * 10 seconds means 100 messages arrive by the time the first listener finishes its 10 second task. The 101st listener will handle the 101st message, and subsequent listeners will finish in time to keep up.) If you need 1 MB of RAM per listener, you'll need 101 MB RAM just to process all the messages on one server. You'll need a similar estimate for CPU as well.

It might be wise to think about multiple queues on multiple servers and load balancing between them if one server isn't sufficient.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜