mirror of
https://github.com/EvolutionAPI/evolution-api.git
synced 2025-12-18 19:32:21 -06:00
feat: Added rabbitmq to send events
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import * as amqp from 'amqplib/callback_api';
|
||||
|
||||
import { configService, Rabbitmq } from '../config/env.config';
|
||||
import { Logger } from '../config/logger.config';
|
||||
|
||||
const logger = new Logger('AMQP');
|
||||
@@ -8,7 +9,8 @@ let amqpChannel: amqp.Channel | null = null;
|
||||
|
||||
export const initAMQP = () => {
|
||||
return new Promise<void>((resolve, reject) => {
|
||||
amqp.connect('amqp://admin:admin@localhost:5672', (error, connection) => {
|
||||
const uri = configService.get<Rabbitmq>('RABBITMQ').URI;
|
||||
amqp.connect(uri, (error, connection) => {
|
||||
if (error) {
|
||||
reject(error);
|
||||
return;
|
||||
@@ -25,7 +27,7 @@ export const initAMQP = () => {
|
||||
channel.assertExchange(exchangeName, 'topic', { durable: false });
|
||||
amqpChannel = channel;
|
||||
|
||||
logger.log('Serviço do RabbitMQ inicializado com sucesso.');
|
||||
logger.log('AMQP initialized');
|
||||
resolve();
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user