Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

RabbitMQ - Regex Implementation Topic Exchange

Suppose, If I have a binding key as "a.b.*" then I can use the routing keys as a.b.1, a.b.2, a.b.3 , a.b.4 and so on.

I want the queue to accept messages from the all these routing keys except the routing key "a.b.3". How can that be implemented?

Or is there any way I can use regex for my binding key instead of just the wildcard characters "*" and "#".

like image 800
Sagar Rout Avatar asked Sep 13 '16 05:09

Sagar Rout


People also ask

How do I use topic Exchange in RabbitMQ?

Topic exchange is a built-in exchange in RabbitMQ, enabling the use of wildcards in the binding key. In RabbitMQ, messages are published to an exchange and, depending on the type of exchange, the message gets routed to one or more queues.

How does a fanout exchange work in RabbitMQ?

A fanout exchange routes messages to all of the queues that are bound to it and the routing key is ignored. If N queues are bound to a fanout exchange, when a new message is published to that exchange a copy of the message is delivered to all N queues. Fanout exchanges are ideal for the broadcast routing of messages.

How does RabbitMQ define exchange?

Exchanges are message routing agents, defined by the virtual host within RabbitMQ. An exchange is responsible for routing the messages to different queues with the help of header attributes, bindings, and routing keys. A binding is a "link" that you set up to bind a queue to an exchange.


1 Answers

No; there's no regex, just the two wildcards.

You can use multiple bindings though - you would have to explicitly bind the queue with a.b.1, a.b.3, a.b.4, but then, you might as well just use a direct exchange.

like image 146
Gary Russell Avatar answered Sep 28 '22 16:09

Gary Russell