Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Passing a :client option to producers #26

Closed
Ciboulette opened this issue Jun 25, 2019 · 2 comments
Closed

Passing a :client option to producers #26

Ciboulette opened this issue Jun 25, 2019 · 2 comments

Comments

@Ciboulette
Copy link

Hello guys,

I would like to use broadway_rabbitmq, because I think that it's a great package but I would also be able to create my queue directly from my application and also being able to setup few things before consuming it.

Why is not possible to implement a client by using BroadwayRabbitMQ.RabbitmqClient behaviour and call it in the broadway.start_link/2

def start_link(_opts) do
      Broadway.start_link(__MODULE__,
        name: __MODULE__,
        producers: [
          default: [
            module: {BroadwayRabbitMQ.Producer,
              client: MyModule.Client
              queue: "my_queue",
            },
            stages: 2
          ]
        ],
        processors: [
          default: [
            stages: 50
          ]
        ]
      )
    end

By reading the code, I had the impression that it was possible because of this line: https://github.com/plataformatec/broadway_rabbitmq/blob/1ba40e62f079ad2277d7ef6b253872f31065fb78/lib/broadway_rabbitmq/producer.ex#L118

Can you tell me if it is something you will give the ability to the users to do?

@msaraiva
Copy link
Contributor

Hi @Ciboulette!

The :client option for the BroadwayRabbitMQ.Producer is private and it only exists so we can replace the client by a fake one during tests. This happens because unlike BroadwaySQS.Producer, which is client agnostic, the BroadwayRabbitMQ.Producer was designed to work with amqp and it can only handle messages from that client.

I would also be able to create my queue directly from my application and also being able to setup few things before consuming it.

If you need to initialize queues or anything else that is not supported by the configuration, we recommend the approach suggested here.

Is that solution feasible for your case? If not, I'm afraid the only other way would be to create a custom producer.

@Ciboulette
Copy link
Author

Ok thanks @msaraiva I guess it should be feasible ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants