File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -46,6 +46,9 @@ REDIS_ENABLED=true
4646REDIS_URI = redis://redis:6379
4747REDIS_PREFIX_KEY = evdocker
4848
49+ RABBITMQ_ENABLED = true
50+ RABBITMQ_URI = amqp://guest:guest@rabbitmq:5672
51+
4952# Global Webhook Settings
5053# Each instance's Webhook URL and events will be requested at the time it is created
5154# # Define a global webhook that will listen for enabled events from all instances
Original file line number Diff line number Diff line change @@ -51,6 +51,9 @@ ENV REDIS_ENABLED=false
5151ENV REDIS_URI=redis://redis:6379
5252ENV REDIS_PREFIX_KEY=evolution
5353
54+ ENV RABBITMQ_ENABLED=false
55+ ENV RABBITMQ_URI=amqp://guest:guest@rabbitmq:5672
56+
5457ENV WEBHOOK_GLOBAL_URL=
5558ENV WEBHOOK_GLOBAL_ENABLED=false
5659
Original file line number Diff line number Diff line change @@ -61,6 +61,11 @@ export type Redis = {
6161 PREFIX_KEY : string ;
6262} ;
6363
64+ export type Rabbitmq = {
65+ ENABLED : boolean ;
66+ URI : string ;
67+ } ;
68+
6469export type EventsWebhook = {
6570 APPLICATION_STARTUP : boolean ;
6671 QRCODE_UPDATED : boolean ;
@@ -116,6 +121,7 @@ export interface Env {
116121 CLEAN_STORE : CleanStoreConf ;
117122 DATABASE : Database ;
118123 REDIS : Redis ;
124+ RABBITMQ : Rabbitmq ;
119125 LOG : Log ;
120126 DEL_INSTANCE : DelInstance ;
121127 WEBHOOK : Webhook ;
@@ -201,6 +207,10 @@ export class ConfigService {
201207 URI : process . env . REDIS_URI ,
202208 PREFIX_KEY : process . env . REDIS_PREFIX_KEY ,
203209 } ,
210+ RABBITMQ : {
211+ ENABLED : process . env ?. RABBITMQ_ENABLED === 'true' ,
212+ URI : process . env . RABBITMQ_URI ,
213+ } ,
204214 LOG : {
205215 LEVEL : process . env ?. LOG_LEVEL . split ( ',' ) as LogLevel [ ] ,
206216 COLOR : process . env ?. LOG_COLOR === 'true' ,
Original file line number Diff line number Diff line change @@ -79,6 +79,10 @@ REDIS:
7979 URI : " redis://localhost:6379"
8080 PREFIX_KEY : " evolution"
8181
82+ RABBITMQ :
83+ ENABLED : false
84+ URI : " amqp://guest:guest@localhost:5672"
85+
8286# Global Webhook Settings
8387# Each instance's Webhook URL and events will be requested at the time it is created
8488WEBHOOK :
Original file line number Diff line number Diff line change 11import * as amqp from 'amqplib/callback_api' ;
22
3+ import { configService , Rabbitmq } from '../config/env.config' ;
34import { Logger } from '../config/logger.config' ;
45
56const logger = new Logger ( 'AMQP' ) ;
@@ -8,7 +9,8 @@ let amqpChannel: amqp.Channel | null = null;
89
910export const initAMQP = ( ) => {
1011 return new Promise < void > ( ( resolve , reject ) => {
11- amqp . connect ( 'amqp://admin:admin@localhost:5672' , ( error , connection ) => {
12+ const uri = configService . get < Rabbitmq > ( 'RABBITMQ' ) . URI ;
13+ amqp . connect ( uri , ( error , connection ) => {
1214 if ( error ) {
1315 reject ( error ) ;
1416 return ;
@@ -25,7 +27,7 @@ export const initAMQP = () => {
2527 channel . assertExchange ( exchangeName , 'topic' , { durable : false } ) ;
2628 amqpChannel = channel ;
2729
28- logger . log ( 'Serviço do RabbitMQ inicializado com sucesso. ' ) ;
30+ logger . log ( 'AMQP initialized ' ) ;
2931 resolve ( ) ;
3032 } ) ;
3133 } ) ;
You can’t perform that action at this time.
0 commit comments