Skip to content

Commit

Permalink
rabbitmq
Browse files Browse the repository at this point in the history
  • Loading branch information
DavidsonGomes committed Mar 27, 2024
1 parent 0b23153 commit ec79864
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
7 changes: 4 additions & 3 deletions src/libs/amqp.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ let amqpChannel: amqp.Channel | null = null;
export const initAMQP = () => {
return new Promise<void>((resolve, reject) => {
const uri = configService.get<Rabbitmq>('RABBITMQ').URI;
const exchangeName = configService.get<Rabbitmq>('RABBITMQ').EXCHANGE_NAME ?? 'evolution_exchange';
amqp.connect(uri, (error, connection) => {
if (error) {
reject(error);
Expand All @@ -23,6 +22,8 @@ export const initAMQP = () => {
return;
}

const exchangeName = 'evolution_exchange';

channel.assertExchange(exchangeName, 'topic', {
durable: true,
autoDelete: false,
Expand Down Expand Up @@ -50,7 +51,7 @@ export const initQueues = (instanceName: string, events: string[]) => {

queues.forEach((event) => {
const amqp = getAMQP();
const exchangeName = configService.get<Rabbitmq>('RABBITMQ').EXCHANGE_NAME ?? instanceName;
const exchangeName = instanceName ?? 'evolution_exchange';

amqp.assertExchange(exchangeName, 'topic', {
durable: true,
Expand Down Expand Up @@ -80,7 +81,7 @@ export const removeQueues = (instanceName: string, events: string[]) => {
return `${event.replace(/_/g, '.').toLowerCase()}`;
});

const exchangeName = configService.get<Rabbitmq>('RABBITMQ').EXCHANGE_NAME ?? instanceName;
const exchangeName = instanceName ?? 'evolution_exchange';

queues.forEach((event) => {
const amqp = getAMQP();
Expand Down
3 changes: 1 addition & 2 deletions src/whatsapp/services/whatsapp.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import {
Database,
HttpServer,
Log,
Rabbitmq,
Sqs,
Webhook,
Websocket,
Expand Down Expand Up @@ -686,7 +685,7 @@ export class WAStartupService {

if (amqp) {
if (Array.isArray(rabbitmqLocal) && rabbitmqLocal.includes(we)) {
const exchangeName = this.configService.get<Rabbitmq>('RABBITMQ').EXCHANGE_NAME ?? this.instanceName;
const exchangeName = this.instanceName ?? 'evolution_exchange';

amqp.assertExchange(exchangeName, 'topic', {
durable: true,
Expand Down

0 comments on commit ec79864

Please sign in to comment.