Wednesday, February 08, 2012

ActiveMQ Recommendations (2) Consumer Configuration

Exclusive consumer

1.     In a multiple-consumer scenario, messages are processed concurrently and the sequential processing cannot be guaranteed. Exclusive consumer can be used to guarantee the order of message processing.
2.     The exclusive consumer for ActiveMQ can be configured by using the queue parameter when creating connections with the broker.
Instead of using the queue name such as “YELEI.TEST”, “YELEI.TEST?consumer.exclusive=true” should be used.

Message Prefetch

1.       In order maximize the performance of message consumers, by default ActiveMQ pushes a certain amount of messages to consumers via queue connections. By default, the prefetch size is 1000 for persistent messages and non-persistent messages. In case of slow consumers processing an amount of big files, probably the prefetch size should be decreased.
Please note in a multiple-consumer scenario, the messages being prefetched by one consumer will not be available for other consumers unless the consumer is considered inactive. This feature would probably harm the sequential processing of messages.
2.       The prefetch size is configured per queue or per connection.
Example: “tcp://localhost:61616?jms.prefetchPolicy.queuePrefetch=100” or "
YELEI.TEST?consumer.prefetchSize=100"

No comments: