Two queues are bound to a topic exchange with the following routing keys:
Queue A, bound with routing key pattern match *.foo
Queue B, bound with routing key pattern match *.bar
I'd like to add a third queue to this exchange that receives messages that are neither foo
messages nor bar
messages. If I bind this queue with a #
routing key, I naturally get all messages I need, but including foo
's and bar
's which I don't want.
Any way to route messages patching a pattern NOT *.foo
AND NOT *.bar
?
When special characters "*" (star) and "#" (hash) aren't used in bindings, the topic exchange will behave just like a direct one.
In this type of exchange, messages are sent to queues based on the routing key. This means that messages sent to a topic exchange must have a specific routing key that must be a list of words, delimited by dots (example, 'acs. deviceoperations.
AMQP allows for various guaranteed messaging modes specifying a message be sent: At-most-once(sent one time with the possibility of being missed). At-least-once (guaranteeing delivery with the possibility of duplicated messages). Exactly-once (guaranteeing a one-time only delivery).
A direct exchange delivers messages to queues based on a message routing key. The routing key is a message attribute added to the message header by the producer. Think of the routing key as an "address" that the exchange is using to decide how to route the message.
If you want to catch all messages that doesn't match any bindings, that can be done with Alternate Exchange.
Add alternate exchange for existent one and collect all messages from that alternate exchanges:
standard workflow --> [main exchange (topic)]
| --> via binding *.foo --> [foo queue]
| --> via binding *.bar --> [bar queue]
v
[alternate exchange (let it be topic too)]
--> via binding * --> []
For more specific cases when you have N bindings but you want to catch all messages that doesn't match M bindings (where M < N) it is more problematic, but technically can be done via Dead Letter Exchange and then publish it to custom exchange where you have only M bindings, and then apply case with Alternate Exchange. But it even sounds rusty, not even think about performance degradation (applied only if you have really high messages flow).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With