Search code examples
javajmsactivemq-classicjms-topic

Can ActiveMQ topics be partitioned such that it uses key in the messages to determine which partition to publish message to?


I have application A which publishes messages to ActiveMQ queues q1 and q2 and I have two consumers c1 and c2 connected q1 and q2 separately. The message format for both c1 and c2 are different , thats why I am using two separate queues.

Is it possible to use a single topic with ActiveMQ, which it further partitions into p1 and p2, and have c1 subscribe to p1 and c2 subscribe to p2? A can uses key in the messages to determine the partition to subscribe to. Is this possible using ActiveMQ?


Solution

  • Yes. JMS supports SQL 92 syntax for creating queries that consumers can use to get just the messages they want. See the JMS selector in section 9.1.8 JMS Spec.

    Also, ActiveMQ doc ActiveMQ Selectors

    Also, ActiveMQ server-side routing using selectors and filtered destinations (see section second from the bottom) Filtered Destinations