A question about `subscribe` with `block: true`

96 views
Skip to first unread message

Evgeniy Fateev

unread,
Jun 15, 2020, 4:42:58 AM6/15/20
to Ruby RabbitMQ libraries
Hi, guys! Recently I've found that it's strongly discouraged to use `Bunny::Queue#subscribe` with `block: true` option (https://groups.google.com/d/msg/ruby-amqp/yRpOup_Qja4/UbnS6QhQAgAJ).

If possible, can somebody help me understand why using `block: true` option is bad for blocking the main thread? It is quite convenient if your application just a consumer of the queue and you need to start it and keep the main thread alive.

Also what are the alternative possibilities for doing this without `block: true`?

Thanks in advance!


Evgeniy Fateev

unread,
Jun 15, 2020, 6:31:48 AM6/15/20
to Ruby RabbitMQ libraries
Looks like `loop { sleep 1 }` is a straightforward way to keep main thread alive.

But still curious about `block: true` considerations.

Michael Klishin

unread,
Jun 24, 2020, 5:46:28 PM6/24/20
to Ruby RabbitMQ libraries
It does not work well with automatic connection recovery. There is no easy way to cancel such consumer.
It's just too limited to be useful beyond basic tutorials and experiments.
> --
> Bunny: http://rubybunny.info
> March Hare: http://rubymarchhare.info
>
> IRC: #rabbitmq on irc.freenode.net
>
> Post to the group: ruby...@googlegroups.com | unsubscribe: ruby-amqp+...@googlegroups.com
> ---
> You received this message because you are subscribed to the Google Groups "Ruby RabbitMQ libraries" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to ruby-amqp+...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/ruby-amqp/86d4ca91-5f03-493a-87f0-ce2338074061o%40googlegroups.com.

Reply all
Reply to author
Forward
0 new messages