From ce020251eac085fc1a4fdf434c862ae08fbbc86d Mon Sep 17 00:00:00 2001 From: skadefro Date: Tue, 16 Jan 2024 12:14:02 +0100 Subject: [PATCH] quick fix, not parsing exchange name proberly --- OpenFlow/src/amqpwrapper.ts | 14 +++++++++----- package.json | 2 +- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/OpenFlow/src/amqpwrapper.ts b/OpenFlow/src/amqpwrapper.ts index 837d96d3..53e29987 100644 --- a/OpenFlow/src/amqpwrapper.ts +++ b/OpenFlow/src/amqpwrapper.ts @@ -392,6 +392,8 @@ export class amqpwrapper extends events.EventEmitter { if(exchange.name == "openflow") { return } + var exchangename = exchange; + if(exchange.name != null) exchangename = exchange.name; // @ts-ignore let { algorithm, routingkey, exclusive } = exchange; if(algorithm == null || algorithm == "") algorithm = "fanout" @@ -399,14 +401,14 @@ export class amqpwrapper extends events.EventEmitter { if(exclusive == null || exclusive == "") exclusive = true const AssertExchangeOptions: any = Object.assign({}, (amqpwrapper.Instance().AssertExchangeOptions)); AssertExchangeOptions.exclusive = exclusive; - // if (exchange.name != Config.amqp_dlx && exchange.name != "openflow" && exchange.name != "openflow_logs") AssertExchangeOptions.autoDelete = true; + // if (exchangename != Config.amqp_dlx && exchangename != "openflow" && exchangename != "openflow_logs") AssertExchangeOptions.autoDelete = true; AssertExchangeOptions.autoDelete = false; // try and create exchange - if(! await this.PreAssertExchange(exchange.name, algorithm, AssertExchangeOptions)) { + if(! await this.PreAssertExchange(exchangename, algorithm, AssertExchangeOptions)) { // config differs, so delete and recreate - await this.checkAndDeleteExchange(exchange.name); - await this.PreAssertExchange(exchange.name, algorithm, AssertExchangeOptions); + await this.checkAndDeleteExchange(exchangename); + await this.PreAssertExchange(exchangename, algorithm, AssertExchangeOptions); } // await amqpwrapper.Instance().AddExchangeConsumer( // Crypt.rootUser(), exchange.name, algorithm, routingkey, AssertExchangeOptions, Crypt.rootToken(), false, null, parent); @@ -421,6 +423,7 @@ export class amqpwrapper extends events.EventEmitter { // if (exchange != Config.amqp_dlx && exchange != "openflow" && exchange != "openflow_logs") q.ExchangeOptions.autoDelete = true; q.ExchangeOptions.autoDelete = false; q.exchange = exchange; q.algorithm = algorithm; q.routingkey = routingkey; q.callback = callback; + await this.PreRegisterExchange(exchange, span) const _ok = await this.channel.assertExchange(q.exchange, q.algorithm, q.ExchangeOptions); if (addqueue) { let AssertQueueOptions = null; @@ -542,7 +545,7 @@ export class amqpwrapper extends events.EventEmitter { if(exchange != "openflow" && exchange != "openflow_logs") { // console.log("publishing to exchange: " + exchange + " routingkey: " + routingkey + " correlationId: " + correlationId); } - this.PreRegisterExchange + await this.PreRegisterExchange(exchange, span) this.channel.publish(exchange, routingkey, Buffer.from(data), options); } } @@ -593,6 +596,7 @@ export class amqpwrapper extends events.EventEmitter { if(exchange != "openflow" && exchange != "openflow_logs") { // console.log("publishing to exchange: " + exchange + " routingkey: " + routingkey + " correlationId: " + correlationId); } + await this.PreRegisterExchange(exchange, span) this.channel.publish(exchange, routingkey, Buffer.from(data), options); } } diff --git a/package.json b/package.json index 1ccca95e..ba77ef45 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@openiap/openflow", - "version": "1.5.8.14", + "version": "1.5.8.18", "description": "Simple wrapper around NodeRed, RabbitMQ and MongoDB to support a more scaleable NodeRed implementation.\r Also the \"backend\" for [OpenRPA](https://github.com/skadefro/OpenRPA)", "main": "index.js", "scripts": {