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

Support for disabling consumers using an application config #98

Closed
theabuitendyk opened this issue Jan 21, 2020 · 5 comments · Fixed by #99
Closed

Support for disabling consumers using an application config #98

theabuitendyk opened this issue Jan 21, 2020 · 5 comments · Fixed by #99

Comments

@theabuitendyk
Copy link

I have many instances of my application running, some of which I'd like to consume from RabbitMQ queues and others that should be dedicated to serving API requests.

I'm using the RabbitSubscribe decorator on a service method to connect a consumer.

@RabbitSubscribe({
    exchange: 'exampleExchange.created',
    routingKey: 'exampleExchange.*',
    queue: 'exampleExchange.created',
  })
  public async process(event): Promise<void> {
    ...
  }

Is there a way to stop this from consuming from the queue based on my application config, while allowing the application to publish to the same exchanges/queues?

@WonderPanda
Copy link
Collaborator

WonderPanda commented Jan 21, 2020

At first I thought that you simply wanted to disable all RabbitMQ behavior for certain instances of your application. If this were the case, you can just conditionally build up your imports array based on an environment/config variable and exclude the call to RabbitMQModule.forRoot/forRootAsync.

Since you also want to be able to still interact with the AmqpConnection to be able to publish messages however, this would require some tweaking to the library.

I don't see a problem with adding in an additional configuration option that will allow you to control whether or not handlers get attached to RabbitMQ though since I can see this being a common use case that will come up. It shouldn't be a large change, I'll try to get a new package version pushed this week

@theabuitendyk
Copy link
Author

Thanks for your help @WonderPanda!

@WonderPanda
Copy link
Collaborator

@theabuitendyk This feature is now available in version 1.10.0

@priyankinfinnov
Copy link

priyankinfinnov commented Feb 9, 2021

Is there a way to register dynamically on the fly @WonderPanda @theabuitendyk ?

Context: I am writing a e2e/integration test for a distributed system. And i want to hold the queue consumer for some time. So i can use registerHandlers flag but when i want them to be executed how do i register dynamically via code?

@WonderPanda
Copy link
Collaborator

@priyankinfinnov You can inject the AmqpConnection and interact directly with it to register subscriptions/rpc etc

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

Successfully merging a pull request may close this issue.

3 participants