nestjs
nestjs copied to clipboard
rabbitmq: direct sending to queue without the need for exchanges
example from rabbitmq library link
Hi, you can simply use AMQPConnection
import { AmqpConnection } from '@golevelup/nestjs-rabbitmq';
import { Injectable } from '@nestjs/common';
@Injectable()
export class Service {
constructor(private readonly amqpConnection: AmqpConnection) {}
public async handle() {
this.amqpConnection.channel.sendToQueue(
'queue-name',
Buffer.from(JSON.stringify({
pattern: 'pattern',
})),
);
}
}