nestjs icon indicating copy to clipboard operation
nestjs copied to clipboard

rabbitmq: direct sending to queue without the need for exchanges

Open melonges opened this issue 10 months ago • 1 comments

example from rabbitmq library link

melonges avatar Apr 17 '24 17:04 melonges

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',
       })),
    );
  }
}

DOMEYD avatar May 02 '24 12:05 DOMEYD