Erlang/OTP Forums

Author Message

<  RabbitMQ mailing list  ~  Exchange-queue binding ?

Guest
Posted: Fri Nov 16, 2007 2:36 am Reply with quote
Guest
Hi,

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:

msg->pq1
msg->pq2

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.

Any ideas?

Thanks

Brian

_______________________________________________
rabbitmq-discuss mailing list
rabbitmq-discuss@lists.rabbitmq.com
http://lists.rabbitmq.com/cgi-bin/mailman/listinfo/rabbitmq-discuss
Post recived from mailinglist
0x6e6562
Posted: Fri Nov 16, 2007 8:04 am Reply with quote
User Joined: 12 Jul 2007 Posts: 250
Brian,

On 16 Nov 2007, at 02:35, Brian Granger wrote:
> The publisher needs to be able to send messages to arbirary subsets of
> the priviate queues.
--snip--
>
> 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.
>

This seems very producer driven. Can I ask why the producer needs to
know about subsets of consumers - are context specific packets of work
being divided up and farmed out to known consumers who maintain state
across the consumption of different messages?

>
> I suppose this also might be possible with header exchange types, but
> it is not obvious how to do that.

It does sound like you're trying to achieve predicate based routing
which would be suited to the header exchange type. Unfortunately the
header exchange is not yet implemented in rabbit.

Ben

_______________________________________________
rabbitmq-discuss mailing list
rabbitmq-discuss@lists.rabbitmq.com
http://lists.rabbitmq.com/cgi-bin/mailman/listinfo/rabbitmq-discuss
Post recived from mailinglist
View user's profile Send private message
Guest
Posted: Fri Nov 16, 2007 5:33 pm Reply with quote
Guest
> On 16 Nov 2007, at 02:35, Brian Granger wrote:
> > The publisher needs to be able to send messages to arbirary subsets of
> > the priviate queues.
> --snip--
> >
> > 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.
> >
>
> This seems very producer driven. Can I ask why the producer needs to
> know about subsets of consumers - are context specific packets of work
> being divided up and farmed out to known consumers who maintain state
> across the consumption of different messages?

Yes, this is exactly the case. The consumers maintain a large amount
of state, and particular message are sent to particular consumers to
change that state.

> >
> > I suppose this also might be possible with header exchange types, but
> > it is not obvious how to do that.
>
> It does sound like you're trying to achieve predicate based routing
> which would be suited to the header exchange type. Unfortunately the
> header exchange is not yet implemented in rabbit.

Ahh, I didn't know that the header exchange wasn't implemented yet.
What about doing this using a topic exchange?

Thanks

Brian

> Ben
>
> _______________________________________________
> rabbitmq-discuss mailing list
> rabbitmq-discuss@lists.rabbitmq.com
> http://lists.rabbitmq.com/cgi-bin/mailman/listinfo/rabbitmq-discuss
>

_______________________________________________
rabbitmq-discuss mailing list
rabbitmq-discuss@lists.rabbitmq.com
http://lists.rabbitmq.com/cgi-bin/mailman/listinfo/rabbitmq-discuss
Post recived from mailinglist
Guest
Posted: Sat Nov 17, 2007 8:04 am Reply with quote
Guest
Brian,

Brian Granger wrote:

> Ahh, I didn't know that the header exchange wasn't implemented yet.

The reason they aren't implemented is that they are not part of the AMQP
0-8 spec, which is what RabbitMQ conforms to. They were introduced in
AMQP 0-9.

> What about doing this using a topic exchange?

Yep. That should work.

> rabbit_exchange:topic_matches(<<"#.foo.#">>, <<"foo.bar.baz.boo">>).
true
> rabbit_exchange:topic_matches(<<"#.bar.#">>, <<"foo.bar.baz.boo">>).
true
> rabbit_exchange:topic_matches(<<"#.baz.#">>, <<"foo.bar.baz.boo">>).
true
> rabbit_exchange:topic_matches(<<"#.boo.#">>, <<"foo.bar.baz.boo">>).
true
> rabbit_exchange:topic_matches(<<"#.moo.#">>, <<"foo.bar.baz.boo">>).
false


Matthias.

_______________________________________________
rabbitmq-discuss mailing list
rabbitmq-discuss@lists.rabbitmq.com
http://lists.rabbitmq.com/cgi-bin/mailman/listinfo/rabbitmq-discuss
Post recived from mailinglist

Display posts from previous:  

All times are GMT
Page 1 of 1
This forum is locked: you cannot post, reply to, or edit topics.

Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum