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

Initializing Rabbit Module creates random queues #667

Closed
shreyassood opened this issue Dec 8, 2023 · 6 comments
Closed

Initializing Rabbit Module creates random queues #667

shreyassood opened this issue Dec 8, 2023 · 6 comments
Labels

Comments

@shreyassood
Copy link

shreyassood commented Dec 8, 2023

On initializing a module with a queue specified, the library creates random queues if createQueueIfNotExists is on.

This happens at

await channel.assertQueue(configuredQueue.name, configuredQueue.options);
within the setupQueuesWithBindings method.

The setupQueue method expects a subscriptionsOptions object of type MessageHandlerOptions but is passed in an object of type RabbitMQQueueConfig. This object does not have the queue property

queue: queueName = '',
} = subscriptionOptions;
and causes Rabbit to initialize a queue with a [random name] (https://www.rabbitmq.com/queues.html#server-named-queues).

Screenshot 2023-12-08 at 5 45 28 PM

Also on a side note: should assertQueue not create a queue at

await channel.assertQueue(configuredQueue.name, configuredQueue.options);
regardless anyway (createQueueIfNotExists) in this case shouldn't matter?

@liudichen
Copy link

I also encountered this issue, and it's not just the queue attribute, but also the queueOptions attribute with different names in the two configurations

maybe should modify this line:

this.setupQueue(configuredQueue, channel);

to

this.setupQueue({...configuredQueue,queue: configuredQueue.name,queueOptions:configuredQueue.options}, channel)

ttshivers added a commit to ttshivers/nestjs that referenced this issue Jan 16, 2024
This is an attempt to fix the issue where this library doesn't pass the right arguments to
setupQueue in setupQueuesWithBindings. In addition, this removes the duplicate setup that
setupQueuesWithBindings was doing that setupQueue alredy does.

re golevelup#667
@underfisk
Copy link
Contributor

The next version shall include the fix for this, bumping here for @WonderPanda

@huantaoliu
Copy link
Contributor

nice

@shreyassood
Copy link
Author

Awesome, thanks for working on this!

@underfisk
Copy link
Contributor

Awesome, thanks for working on this!

All the merit goes to @ttshivers ! He's doing an amazing job helping out

@trickaugusto
Copy link

Hello everyone!

I had the same problem, but I used version 5.0.0 and it didn't solve the problem...
Has this gone to production?

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

No branches or pull requests

5 participants