Skip to content

Commit 623efd8

Browse files
Merge pull request #1498 from thrsouza/main
Inclusão do parâmetro frame_max para compatibilidade com RabbitMQ 4.1+
2 parents 373a531 + 3297364 commit 623efd8

File tree

3 files changed

+16
-1
lines changed

3 files changed

+16
-1
lines changed

.env.example

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ DATABASE_DELETE_MESSAGE=true
5050
RABBITMQ_ENABLED=false
5151
RABBITMQ_URI=amqp://localhost
5252
RABBITMQ_EXCHANGE_NAME=evolution
53+
RABBITMQ_FRAME_MAX=8192
5354
# Global events - By enabling this variable, events from all instances are sent in the same event queue.
5455
RABBITMQ_GLOBAL_ENABLED=false
5556
# Prefix key to queue name

src/api/integrations/event/rabbitmq/rabbitmq.controller.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,21 @@ export class RabbitmqController extends EventController implements EventControll
2121

2222
await new Promise<void>((resolve, reject) => {
2323
const uri = configService.get<Rabbitmq>('RABBITMQ').URI;
24+
const frameMax = configService.get<Rabbitmq>('RABBITMQ').FRAME_MAX;
2425
const rabbitmqExchangeName = configService.get<Rabbitmq>('RABBITMQ').EXCHANGE_NAME;
2526

26-
amqp.connect(uri, (error, connection) => {
27+
const url = new URL(uri);
28+
const connectionOptions = {
29+
protocol: url.protocol.slice(0, -1),
30+
hostname: url.hostname,
31+
port: url.port || 5672,
32+
username: url.username || 'guest',
33+
password: url.password || 'guest',
34+
vhost: url.pathname.slice(1) || '/',
35+
frameMax: frameMax
36+
};
37+
38+
amqp.connect(connectionOptions, (error, connection) => {
2739
if (error) {
2840
reject(error);
2941

src/config/env.config.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ export type EventsRabbitmq = {
9595
export type Rabbitmq = {
9696
ENABLED: boolean;
9797
URI: string;
98+
FRAME_MAX: number;
9899
EXCHANGE_NAME: string;
99100
GLOBAL_ENABLED: boolean;
100101
EVENTS: EventsRabbitmq;
@@ -391,6 +392,7 @@ export class ConfigService {
391392
PREFIX_KEY: process.env?.RABBITMQ_PREFIX_KEY,
392393
EXCHANGE_NAME: process.env?.RABBITMQ_EXCHANGE_NAME || 'evolution_exchange',
393394
URI: process.env.RABBITMQ_URI || '',
395+
FRAME_MAX: Number.parseInt(process.env.RABBITMQ_FRAME_MAX) || 8192,
394396
EVENTS: {
395397
APPLICATION_STARTUP: process.env?.RABBITMQ_EVENTS_APPLICATION_STARTUP === 'true',
396398
INSTANCE_CREATE: process.env?.RABBITMQ_EVENTS_INSTANCE_CREATE === 'true',

0 commit comments

Comments
 (0)