nest icon indicating copy to clipboard operation
nest copied to clipboard

@nestjs/microservices should handle RabbitMQ bindings and auto-generated queues

Open pitazzo opened this issue 1 year ago • 0 comments
trafficstars

Is there an existing issue that is already proposing this?

  • [X] I have searched the existing issues

Is your feature request related to a problem? Please describe it

The behavior of @nestjs/microservices while creating a new microservice app does not match the behavior expected to the regular amqplib package. So far, for a configuration as this, I've encountered this mismatch in two situations:

  const app = await NestFactory.createMicroservice(AppModule, {
    transport: Transport.RMQ,
    options: {
      urls: ['amqp://localhost:5672'],
      queue: '',
      queueOptions: {
        exclusive: true,
      },
      noAck: false,
      exchange: 'a.b.c',
      routingKey: 'x.y.*.z',
    },
  });
  await app.listen();
  • Passing an empty string as queue name won't create an exclusive queue with a name in the form amq.gen-cf6fXOViIyb..., instead creates one called default.
  • Specifying exchange and routingKey should bind the queue to the exchange, and that does not happen.

Describe the solution you'd like

For the given situations:

  • The queues should be named in the expected format
  • The binding should automatically happen

Teachability, documentation, adoption, migration strategy

  • In the RabbitMQ docs should be covered in detail which parameters can be passes to the options object.
  • Final behavior should be the same as described here.

What is the motivation / use case for changing the behavior?

With the current behavior, some basic features of RabbitMQ can be achieved out of the box. Instead, some manual tweaking is needed.

pitazzo avatar Aug 30 '24 11:08 pitazzo