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

Multiple RabbitSubscribe Decorators in the Same Provider rotates through decorated methods rather than invoking the correct method #655

Open
ianjkaplan opened this issue Oct 16, 2023 · 7 comments
Labels

Comments

@ianjkaplan
Copy link

ianjkaplan commented Oct 16, 2023

The following is an issue I ran into only after much debugging in the @golevelup/nestjs-rabbitmq package.

Reproduction
Register Provider with multiple RabbitSubscribe decorators that share a queue but subscribe to different topics on an exchange (i.e appointment.schedule.created and appointment.schededule.updated).

import { RabbitSubscribe } from '@golevelup/nestjs-rabbitmq';
import { Injectable } from '@nestjs/common';

@Injectable()
export class AppointmentSchedulingService {
  @RabbitSubscribe({
    exchange: 'exchange1',
    routingKey: 'appointment.schedule.created',
    queue: 'subscribe-queue',
  })
  public async createdHandler(msg: {}) {
    console.log(`Created appointment `, msg);
  }
  @RabbitSubscribe({
    exchange: 'exchange1',
    routingKey: 'appointment.schedule.updated',
    queue: 'subscribe-queue',
  })
  public async updatedHandler(msg: {}) {
    console.log(`Updated appointment `, msg);
  }
}

publish multiple appointment.schedule.created events quickly to the exchange exchange1.

expected behavior

the createdHandler will be invoked twice.

actual behavior

the createdHandler is invoked one time and the updatedHandler is invoked one time.

I would expect that I could register multiple handlers in a provider that get invoked with different routing keys. I would not expect a handler with a different routing key to get invoked.

Any help better understanding the source of this issue would be appreciated and Id be happy to help contribute a solution if one is necessary

@rafaelsanti420
Copy link

why is this closed? im experiencing this right now, this is not fixed in 3.7.0 or 4.0.0

@WonderPanda
Copy link
Collaborator

I agree that this is something that should be addressed but the simple fix right now is to avoid using the same queue name for multiple hanlders. It messes up the bindings and causes your NestJS callback to get registered

@WonderPanda WonderPanda reopened this Oct 24, 2023
@tobecwb
Copy link

tobecwb commented Mar 13, 2024

this problem still occurs in version 5.1.0

@rguzg
Copy link

rguzg commented Jun 6, 2024

This problem still occurs in 5.2.0. Managing queues this way is an important feature for any event driven system; this should be one of your top priorities.

Copy link

github-actions bot commented Oct 1, 2024

This issue is stale because it has been open for 30 days with no activity.

@github-actions github-actions bot added the stale label Oct 1, 2024
@dileepinsurstaq
Copy link

any progress on this?
current i'm using version: 5.5.0

@underfisk
Copy link
Contributor

@dileepinsurstaq Sorry no progress yet, i haven't been able to spend the time to investigate the cause.
If anyone is interested in helping us out I would happily review the PR

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

7 participants