[rabbitmq-discuss] pub-sub part 2: erlang consume
alexis.richardson at cohesiveft.com
Thu Apr 10 10:12:12 BST 2008
On Thu, Apr 10, 2008 at 12:17 AM, Joe Lee <codewalkerjoe at gmail.com> wrote:
> I have published the message asynchronously to the exchange. Now to consume
> the messages from the exchange, I can use either BasicGet or BasicConsume.
> When you are consuming messages in pub/sub model, do you have to specify
> what exchange to look for?
The consumer's messages are buffered by a queue Q which you must
explicitly bind, once, to a named exchange E. As you are doing
pub/sub, then E needs to be a Topic exchange. Q will bind to that
exchange with an associative pattern P (tuple of wildcards and routing
keys). Then, E will route messages to Q when their routing keys match
the pattern P. For example "buy.ibm" matches "*.ibm".
> In addition, when you consume message from an
> exchange regardless of messaging model(pub/sub), you still have to declare a
> queue, bind it and consume the message from the queue?
You can consume directly from an exchange. So, yes, you must declare
at least one queue per consumer, bind it to at least one exchange, and
consume messages from the queue. The queue is in effect 'subscribed'
to whichever topics match the binding pattern.
More information about the rabbitmq-discuss