I have a few microservices, which are exposed through an API-Gateway. The gateway takes care of handling authentication and routing into the system. The services behind the
RabbitMQ is supported in nestjs as a microservice. If you want your application to support both http requests and a message broker, you can create a hybrid application.
// Create your regular nest application.
const app = await NestFactory.create(ApplicationModule);
// Then combine it with a RabbitMQ microservice
const microservice = app.connectMicroservice({
transport: Transport.RMQ,
options: {
urls: [`amqp://localhost:5672`],
queue: 'my_queue',
queueOptions: { durable: false },
},
});
await app.startAllMicroservicesAsync();
await app.listen(3001);