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 70d4eb3 commit 950803b
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
"cross-env": "^7.0.3",
"dayjs": "^1.11.7",
"eventemitter2": "^6.4.9",
"evolution-manager": "^0.4.11",
"evolution-manager": "^0.4.13",
"exiftool-vendored": "^22.0.0",
"express": "^4.18.2",
"express-async-errors": "^3.1.1",
Expand Down
7 changes: 3 additions & 4 deletions src/libs/amqp.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ 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 @@ -22,8 +23,6 @@ export const initAMQP = () => {
return;
}

const exchangeName = 'evolution_exchange';

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

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

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

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

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

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

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

0 comments on commit 950803b

Please sign in to comment.