Search code examples
apache-cameljmsactivemq-classicjms-topicspring-dsl

Routing Logic inside ActiveMQ to specific worker pool


I have a scenario,

I have the same queue configured for SMS and EMAILS.

I want the ActiveMQ to route the message to specific consumer pool i.e. if it is an SMS, then it must be routed to a pool of worker threads for SMS.

So, If I need to scale up the number of SMSs, then I just need to increase the pool size of SMS Worker Pool and not for EMAIL worker pool.

Can I use Apache Camel to implement the routing logic for my requirement???


Solution

  • There are a number of options to support this:

    1. Set a header on each message so the consumers can use JMS selectors to filter the messages.

    2. Use a virtual destination within the ActiveMQ broker (the broker can filter based on message header value): http://activemq.apache.org/virtual-destinations.html

    3. Use a Camel broker component to write a custom interceptor handler: http://activemq.apache.org/broker-camel-component.html

    4. Use a Camel message router or content-based-router as Nayan suggested

    5. Use separate queues per message type (i.e. queue://OUTBOUND.SMS, queue://OUTBOUND.EMAIL..)

    Each has benefits and trade-offs. #1, #4 and #5 do not require any server-side configuration, which is handy for keeping the broker maintenance as low as possible.