golevelup / nestjs

A collection of badass modules and utilities to help you level up your NestJS applications 🚀
MIT License
2.16k stars 244 forks source link

rabbitmq: direct sending to queue without the need for exchanges #726

Closed melonges closed 2 months ago

melonges commented 3 months ago

example from rabbitmq library link

DOMEYD commented 2 months ago

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