Kombu - can a single consumer support multiple exchanges?

Skip to first unread message

Joe

unread,
Jul 18, 2011, 8:34:55 PM7/18/11
to carrot-users
A little bit of an odd question, but can a single Consumer() support
processing from multiple exchanges?

I'm hooking up a little client to a couple of different topic
exchanges, and I'd like to also hook it up to a broadcast (Fanout)
exchange. Is there a good way of supporting this setup other than
creating two Consumer() objects and having them process from their
respective exchanges?

-joe

Ask Solem

unread,
Jul 19, 2011, 5:50:57 AM7/19/11
to carrot...@googlegroups.com


You don't consume from an exchange, but from a queue,
and a Consumer can consume from multiple queues.

Consumer(channel, [q1, q2])


However, you may want to apply different QoS settings, then
you have to use multiple Consumers using different channels.

e.g:


c1 = Consumer(channel, [q1])
c1.qos(prefetch_count=10)
c1.register_callback(handle_message)
c1.consume()

c2 = Consumer(channel, [q2])
c2.qos(prefetch_count=10)
c2.register_callback(handle_broadcast_message)
c2.consume()

while 1:
connection.drain_events()

This way the limits imposed on the first channel,
won't affect broadcast messages.

--
Ask Solem
twitter.com/asksol | +44 (0)7713357179

Joseph Heck

unread,
Jul 19, 2011, 3:05:36 PM7/19/11
to carrot...@googlegroups.com
Ah - sorry for my poor use of the terms - what I meant to ask is can
we have a single consumer work on queues that attach to two different
exchanges? It looks possible...

something like:

broadcast_exchange=Exchange("fanout")
topic_exchange=Exchange("topic")
q1 = Queue(broadcast_exchange)
q2 = Queue(topic_exchange)

c1 = Consumer(channel, [q1, q2])
c1.register_callback(handle_incoming)
c1.consume()

while 1:
connection.drain_events()

?

-joe

> --
> You received this message because you are subscribed to the Google Groups "carrot-users" group.
> To post to this group, send email to carrot...@googlegroups.com.
> To unsubscribe from this group, send email to carrot-users...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/carrot-users?hl=en.
>
>

Reply all
Reply to author
Forward
0 new messages