[rabbitmq-discuss] Exchange-queue binding ?
ellisonbg.net at gmail.com
Fri Nov 16 02:35:37 GMT 2007
I am trying to figure out how to bind a set of queues to an exchange
to get specific type of routing and I can't seem to figure out exactly
how to set things up.
Here is the needed routing pattern:
I have 1 publisher and N consumers. Each consumer has a private queue
and only they consume from.
The publisher needs to be able to send messages to arbirary subsets of
the priviate queues.
So if there are private queues:
pq1, pq2, pq3, pq4, etc.
Publisher needs to be able to send messages to combinations like:
msg -> pq1 + pq2
msg -> pq1 + pq3 + pq4
msg -> pq1+pq2+pq3+pq4
Arbitrary subsets are allowed.
The simple way of doing this is to convert each publish to multiple
publishes to each desired queue:
Thus msg -> pq1 + pq2 becomes:
The problem with this is that the publisher sends the message to the
exchange twice (or N times to send to N private queues). I need a way
of publishing to an exchange only one time per message and then have
the exchange route the message to the appropriate subset of private
queues. I should also mention that the subsets are very dynamic and
completely determined by the publisher.
It seem like I should be able to use a topic exchange, but the amqp
spec is a little vague on exactly how things are matched.
Can I do the following?
pq1: Pattern = #.pq1.#
pq2: Pattern = #.pq2.#
pq1: Pattern = #.pq3.#
And then send messages with routing keys like:
pq1.pq2 (route to pq1 and pq2)
pq1.pq2.pq3 (route to pq1 & pq2 & pq3)
and so on
I suppose this also might be possible with header exchange types, but
it is not obvious how to do that.
More information about the rabbitmq-discuss