har17bar
har17bar

Reputation: 884

NestJS: is there way call microservices rabbitmq from outside

I have one microservice which transporter is rabbitmq and have @MessagePattern('sum'). I wonder if there is a way to simulate call from outside to my microservice messagePattern listener. I guess I can do it in rabbitmq management gui by finding the queue to which the microservice is listening or just by publishing data from my rabbitmq client

Can someone provide the format of payload transferred by rabbitmq that microservice is expecting?

Upvotes: 1

Views: 1152

Answers (1)

har17bar
har17bar

Reputation: 884

Found solution:

const app = await NestFactory.createMicroservice<MicroserviceOptions>(
            AppModule,
            {
                transport: Transport.RMQ,
                options: {
                    urls: ['amqp://localhost:5672'],
                    queue: 'notification',
                    queueOptions: {
                        durable: false,
                    },
                },
            },
        );

So each microservice after running create on queue with name that you pass to options parameter microservice expecting to passing json with key "pattern" and value name of messagePattern for invoking

enter image description here

Upvotes: 2

Related Questions