Dax Durax
Dax Durax

Reputation: 1657

JMS-like Message Selectors for AMQP (ActiveMQ / RabbitMQ)

Is there anything similar to JMS message selectors for RabbitMQ? Or must some code be written to parse and select the messages?

Thanks.

Upvotes: 4

Views: 5655

Answers (2)

wrschneider
wrschneider

Reputation: 18770

AMQP routing key with direct/topic exchanges work well if the selector is always on a single string field. If your selectors are all of the form message_type = 'foo' then you would use message_type as your routing key.

If the message filter uses multiple/different fields, then you could use the amq.match exchange, which would route messages that match any or all header values to the related queue. This would handle selectors like field1 = 'value' OR field2 = 'value' and cases where different consumers selectively consume based on different attributes.

I think JMS message selectors also let you do more complex logic and comparison operators like greater-than, less-than, etc. and I haven't found an equivalent of that with AMQP/RabbitMQ.

Upvotes: 1

Gabriele Santomaggio
Gabriele Santomaggio

Reputation: 22682

It's called "amqp routing key".

You can find the different here:

http://www.wmrichards.com/amqp.pdf

And you can find some example about the routing-key here:

http://www.rabbitmq.com/tutorials/tutorial-four-python.html

Upvotes: 4

Related Questions