@@ -663,6 +663,18 @@ export class WAStartupService {
663663 } ;
664664 }
665665
666+ private assertExchangeAsync = ( channel , exchangeName , exchangeType , options ) => {
667+ return new Promise ( ( resolve , reject ) => {
668+ channel . assertExchange ( exchangeName , exchangeType , options , ( error , ok ) => {
669+ if ( error ) {
670+ reject ( error ) ;
671+ } else {
672+ resolve ( ok ) ;
673+ }
674+ } ) ;
675+ } ) ;
676+ } ;
677+
666678 public async sendDataWebhook < T = any > ( event : Events , data : T , local = true ) {
667679 const webhookGlobal = this . configService . get < Webhook > ( 'WEBHOOK' ) ;
668680 const webhookLocal = this . localWebhook . events ;
@@ -687,22 +699,27 @@ export class WAStartupService {
687699 if ( Array . isArray ( rabbitmqLocal ) && rabbitmqLocal . includes ( we ) ) {
688700 const exchangeName = this . instanceName ?? 'evolution_exchange' ;
689701
690- amqp . assertExchange ( exchangeName , 'topic' , {
702+ // await amqp.assertExchange(exchangeName, 'topic', {
703+ // durable: true,
704+ // autoDelete: false,
705+ // });
706+
707+ await this . assertExchangeAsync ( amqp , exchangeName , 'topic' , {
691708 durable : true ,
692709 autoDelete : false ,
693710 } ) ;
694711
695712 const queueName = `${ this . instanceName } .${ event } ` ;
696713
697- amqp . assertQueue ( queueName , {
714+ await amqp . assertQueue ( queueName , {
698715 durable : true ,
699716 autoDelete : false ,
700717 arguments : {
701718 'x-queue-type' : 'quorum' ,
702719 } ,
703720 } ) ;
704721
705- amqp . bindQueue ( queueName , exchangeName , event ) ;
722+ await amqp . bindQueue ( queueName , exchangeName , event ) ;
706723
707724 const message = {
708725 event,
@@ -717,7 +734,7 @@ export class WAStartupService {
717734 message [ 'apikey' ] = instanceApikey ;
718735 }
719736
720- amqp . publish ( exchangeName , event , Buffer . from ( JSON . stringify ( message ) ) ) ;
737+ await amqp . publish ( exchangeName , event , Buffer . from ( JSON . stringify ( message ) ) ) ;
721738
722739 if ( this . configService . get < Log > ( 'LOG' ) . LEVEL . includes ( 'WEBHOOKS' ) ) {
723740 const logData = {
0 commit comments