Open
Description
when i use RabbitRPC in one controller with multiple actions like this
@RabbitRPC({
exchange: AuthRegister.exchange,
routingKey: AuthRegister.topic,
queue: AuthRegister.queue,
errorBehavior: MessageHandlerErrorBehavior.NACK,
errorHandler: rpcErrorHandler,
})
async register(@Body() dto: AuthRegister.Request) : Promise<AuthRegister.Response> {
const newUser = await this.authService.register(dto);
return { email: newUser.email };
}
@RabbitRPC({
exchange: AuthJWTLogin.exchange,
routingKey: AuthJWTLogin.topic,
queue: AuthJWTLogin.queue,
errorBehavior: MessageHandlerErrorBehavior.NACK,
errorHandler: rpcErrorHandler,
})
async login(@Body() dto: AuthJWTLogin.Request): Promise<AuthJWTLogin.Response> {
const { id } = await this.authService.validateUser(dto.email, dto.password);
return this.authService.login(id);
}
and create request like this
return await this.amqpConnection.request<AuthRegister.Response>({
exchange: AuthRegister.exchange,
routingKey: AuthRegister.topic,
payload: dto,
timeout: 10000
})
one time it works fine and second time i have got error like this
[Nest] 119672 - 06/27/2024, 7:57:17 PM ERROR [AmqpConnection] Received message with invalid routing key: sso.auth.register.command
but if i keep one action it works fine or when i c 56EC hange que name and keep one routing key in queue it works fine
my exchange is topic
and in controller exchange and queue is same for all actions only routing key is diffirent