UNPKG

@bgaldino/nestjs-rabbitmq

Version:

A different way of configuring your RabbitMQ

27 lines (26 loc) 1.45 kB
import { OnApplicationBootstrap } from "@nestjs/common"; import { ChannelWrapper } from "amqp-connection-manager"; import { PublishOptions } from "amqp-connection-manager/dist/types/ChannelWrapper"; export declare class RabbitMQService implements OnApplicationBootstrap { private logType; private logger; onApplicationBootstrap(): void; /** * Check status of the main conenection to the broker. * @returns {number} 1 - Online | 0 - Offline */ checkHealth(): number; /** * Publishes a message to the broker. Every published message needs its exchange and routingKey to be properly routed * @param {string} exchangeName - Name of the exchange * @param {string} routingKey - Publish routing key * @param {T} the message that will be published to RabbitMQ. All messages will be transformed to JSON. * @param {PublishOptions} options - Any custom options that you want to send with the message such as headers or properties * @returns {Promise<boolean>} Returns a promise of confirmation. * If **TRUE** it means that the message arrived and was successfully delivered to an exchange or queue. * If **FALSE** or an error is thrown, the message was not published ! */ publish<T = any>(exchangeName: string, routingKey: string, message: T, options?: PublishOptions): Promise<boolean>; createConsumers(): Promise<ChannelWrapper[]>; private inspectPublisher; }