An question about subscribe for rabbitmq tutorials Erlang version

17 views
Skip to first unread message

linbo liao

unread,
Dec 1, 2014, 10:44:53 AM12/1/14
to rabbitm...@googlegroups.com
Hi,

I already post it in rabbitmq-discuss maillist, repost in this office mail list again.  Sorry for any inconvenience.

I am a newbie to learn rabbitmq tutorials, for subscribe method I have a doubt, need help for clarify. Thanks for advance.

The tutorials code will wait for #basic.consume_ok after sending subscribe request, but for erlang-client-user-guide

The consumer argument is the pid of a process to which the client library will deliver messages. This can be an arbitrary Erlang process, including the process that initiated the subscription. The #'basic.consume_ok'{} notification contains a tag that identifies the subscription. This is used at a later point in time to cancel the subscription. This notification is sent both to the process that created the subscription (as the return value to amqp_channel:subscribe/3) and as a message to the consumer process.

The #basi_consume_ok will return twice, one for process that created the subscription, another for consumer process.

So for the tutorials, process created the subscription and consumer process are same, should it still wait for #basic.consume_ok in receiver statement?  Since subscribe method already returned the notification.

Thanks,
Linbo

Michael Klishin

unread,
Dec 1, 2014, 10:48:51 AM12/1/14
to rabbitm...@googlegroups.com, linbo liao
On 1 December 2014 at 18:44:55, linbo liao (llb...@gmail.com) wrote:
> The tutorials code will wait for #basic.consume_ok after sending
> subscribe request, but for erlang-client-user-guide(http://www.rabbitmq.com/erlang-client-user-guide.html#subscribing)
>
> The consumer argument is the pid of a process to which the client
> library will deliver messages. This can be an arbitrary Erlang
> process, including the process that initiated the subscription.
> The #'basic.consume_ok'{} notification contains a tag that
> identifies the subscription. This is used at a later point in
> time to cancel the subscription. This notification is sent both
> to the process that created the subscription (as the return value
> to amqp_channel:subscribe/3) and as a message to the consumer
> process.
>
> The #basi_consume_ok will return twice, one for process that
> created the subscription, another for consumer process.
>
> So for the tutorials, process created the subscription and consumer
> process are same, should it still wait for #basic.consume_ok
> in receiver statement? Since subscribe method already returned
> the notification.

In this case I'd suggest being prepared to receive it (e.g. if your process is a gen_server)
but not wait for or rely on  it. Just use the returned value.
--
MK

Staff Software Engineer, Pivotal/RabbitMQ

linbo liao

unread,
Dec 1, 2014, 5:39:12 PM12/1/14
to rabbitm...@googlegroups.com, llb...@gmail.com
Thanks MK. I will use returned value to confirm subscribe succeed.

在 2014年12月1日星期一UTC+8下午11时48分51秒,Michael Klishin写道:
Reply all
Reply to author
Forward
0 new messages