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

RabbitMQ Bug Microservices #13455

Open
2 of 12 tasks
thedarkknight197 opened this issue Apr 16, 2024 · 1 comment
Open
2 of 12 tasks

RabbitMQ Bug Microservices #13455

thedarkknight197 opened this issue Apr 16, 2024 · 1 comment

Comments

@thedarkknight197
Copy link

thedarkknight197 commented Apr 16, 2024

Is there an existing issue for this?

  • I have searched the existing issues

Current behavior

all this request was sent without restart server or rabbitmq server

  • first request consumer don't receive message: stackoveflow
  • second request come to consumer - ok
  • future request provide error: There is no matching message handler defined in the remote service - stackoverflow

Minimum reproduction code

not have

Steps to reproduce

Producer

main.ts producer

const app = await NestFactory.create<NestExpressApplication>(MainModule);

app.connectMicroservice<MicroserviceOptions>({
  transport: Transport.RMQ,
  options: {
    urls: ['amqp://' + process.env.RABBIT_HOST + ':5672'],
    queue: 'my_queue',
    queueOptions: {
      durable: false,
    },
    consumerTag: 'Service1',
  },
});

await app.startAllMicroservices();
...
await app.listen(3000);

MainModule

ClientsModule.register([
      {
        name: 'MY_SERVICE',
        transport: Transport.RMQ,
        options: {
          urls: ['amqp://' + process.env.RABBIT_HOST + ':5672'],
          queue: 'tenant_queue',
          queueOptions: {
            durable: false,
          },
        },
      },
    ]),

MainService

constructor(
   ...
    @Inject('MY_SERVICE') private readonly client: ClientProxy,
  ) {}

  @Post()
  endpoint(...) {
     ...
      switchMap((result) =>
        forkJoin({
          result: of(result),
          db: this.client.send('my-event', result),
        }),
      ),
      }),
    );

Consumer

main.ts

const app = await NestFactory.createMicroservice(MainModule, {
    transport: Transport.RMQ,
    options: {
      urls: ['amqp://' + process.env.RABBIT_HOST + ':5672'],
      queue: 'my_queue',
      queueOptions: {
        durable: false,
      },
      consumerTag: 'consumerService',
    },
  });

  await app.listen();

consumerController:

@Controller()
export class ConsumerController {
  constructor(
    ....,
    private readonly connection: PrismaClientManager,
  ) {}

  @MessagePattern('my-event')
  async notify(
    @Payload() { ... }: { ... : ... },
    @Ctx() context: RmqContext,
  ) {
    return ...;
  }
}

Expected behavior

consumer answer to all events sent from rabbitmq provider

Package

  • I don't know. Or some 3rd-party package
  • @nestjs/common
  • @nestjs/core
  • @nestjs/microservices
  • @nestjs/platform-express
  • @nestjs/platform-fastify
  • @nestjs/platform-socket.io
  • @nestjs/platform-ws
  • @nestjs/testing
  • @nestjs/websockets
  • Other (see below)

Other package

No response

NestJS version

10.0.0

Packages versions

 _   _             _      ___  _____  _____  _     _____
| \ | |           | |    |_  |/  ___|/  __ \| |   |_   _|
|  \| |  ___  ___ | |_     | |\ `--. | /  \/| |     | |
| . ` | / _ \/ __|| __|    | | `--. \| |    | |     | |
| |\  ||  __/\__ \| |_ /\__/ //\__/ /| \__/\| |_____| |_
\_| \_/ \___||___/ \__|\____/ \____/  \____/\_____/\___/


[System Information]
OS Version     : Windows 10.0.22631
NodeJS Version : v18.20.2
NPM Version    : 10.5.0

[Nest CLI]
Nest CLI Version : 10.3.2

[Nest Platform Information]
platform-express version : 10.3.3
microservices version    : 10.3.3
schematics version       : 10.1.1
passport version         : 10.0.3
swagger version          : 7.3.0
testing version          : 10.3.3
common version           : 10.3.3
config version           : 3.2.0
core version             : 10.3.3
jwt version              : 10.2.0
cli version              : 10.3.2


### Node.js version

18.20.2

### In which operating systems have you tested?

- [ ] macOS
- [X] Windows
- [ ] Linux

### Other

_No response_
@thedarkknight197 thedarkknight197 added the needs triage This issue has not been looked into label Apr 16, 2024
@kamilmysliwiec
Copy link
Member

Please provide a minimum reproduction repository (Git repository/StackBlitz/CodeSandbox project).

@kamilmysliwiec kamilmysliwiec added needs clarification and removed needs triage This issue has not been looked into labels Apr 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants