dashbitco / broadway_rabbitmq

A Broadway producer for RabbitMQ

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

producers keep failing with declare: [no_wait: true]

fcevado opened this issue · comments

when i set it to declare: [no_wait: true] the producer keeps failing:

[error] Cannot connect to RabbitMQ broker: :ok
[error] Crashing because of unexpected error when connecting to RabbitMQ
[error] GenServer Rmq.Broadway.Producer_0 terminating
** (RuntimeError) unexpected error when connecting to RabbitMQ broker
    (broadway_rabbitmq 0.6.5) lib/broadway_rabbitmq/producer.ex:605: BroadwayRabbitMQ.Producer.handle_connection_failure/2
    (broadway_rabbitmq 0.6.5) lib/broadway_rabbitmq/producer.ex:428: BroadwayRabbitMQ.Producer.handle_info/2
    (broadway 0.6.2) lib/broadway/topology/producer_stage.ex:228: Broadway.Topology.ProducerStage.handle_info/2
    (gen_stage 1.1.0) lib/gen_stage.ex:2108: GenStage.noreply_callback/3
    (stdlib 3.14) gen_server.erl:689: :gen_server.try_dispatch/4
    (stdlib 3.14) gen_server.erl:765: :gen_server.handle_msg/6
    (stdlib 3.14) proc_lib.erl:226: :proc_lib.init_p_do_apply/3
Last message: {:connect, :no_init_client}

elixir: 1.11.3
erlang 23.2.7

I belive the producer needs to wait the proper declare operation to finish before trying to bind the queue to the exchange.

What do you think we should do? Can we even support no_wait: true then?

I belive it can be an issue related to amqp library, according to this PR the option was changed from :no_wait to :nowait and was not supported properly. I gonna try and see the behavior directly with the amqp library. I'll provide more information when i'm done testing.

nowait (or no_wait - AMQP 2.x supports both for the parameter option) means the operation is async. Since you want to make sure the queue is declared before subscribing, I don't recommend you to enable the option there.

Yes, there was a bug on AMQP 1.x with no_wait and it has been fixed on 2.x. However, regardless the bug, I don't think you should use the option with Broadway.

I don't think you should use the option with Broadway.

@josevalim given that feedback from @ono I guess the option could be removed. I want to try more stuff(like setting :nowait to declare and to bind) and see how the producer behaves.

I think we just pass all options through so this should be simply a matter of updating the docs with the best practices. Can you please send a PR?