AMQP Qpid ActiveMQ routing key

151 Views Asked by At

I'm using ActiveMQ "Classic," and I want to use AMQP protocol.

For the moment I am trying to use AMQP 1.0 and the Java client Qpid JMS client 2.2.0 and qpid-amqp-1-0-client-jms 0.32 with Spring Boot 3 and jakarta package.

The final goal is to fully use AMQP and after possibly replace ActiveMQ by another broker without changing my code, but I use VirtualTopic, and if I understand AMQP can do the same thing like VirtualTopic by using "routing key" with wildcard.

I have configure a simple Java sender and consumer and all work fine, but now i want to use "routing key" to publish a message on topic TEST.*, but I'm stuck here and I don't know how to set my routing key with wildcard.

1

There are 1 best solutions below

0
Matt Pavlovich On

Consider inverting your app design to have consumers declare their interest vs the publisher sending to a list (or wildcard match) of destinations.

A good tenant of pub-sub is to separate producers and consumers from addressing and this reduces coupling. This is one of the more powerful features of Virtual Topics-- they are super practical.

There is nothing out-of-spec about using Virtual Topics. Producers simply publish to a topic, and consumers read from queues. This capability is available in several JMS-spec brokers, and does not lock you into ActiveMQ. The difference with ActiveMQ 5 is that the administrative overhead is super low.

  1. Publish message to a 'topic' - "TEST.EVENT"

  2. Any interested consumer registers themselves by connecting and creating a queue (or the queue can be created administratively) "Consumers.APP-1.TEST.EVENT", "Consumers.APP-2.TEST.EVENT", etc. You also have the capability for consumers to register selectors, so they only get filtered messages.

  3. As a bonus, networking brokers in a cluster becomes more straight-forward as their are unexpected hang-ups when clustering topics.

  4. This is not protocol or language specific. You can send/recv using different programming languages (Java, .NET, JavaScript, Pythong, etc) or protocols -- AMQP, JMS (openwire), STOMP, MQTT, etc and it "just works"