From 932097b9a5698d6ca58f4b1a779feebb5d48cf7b Mon Sep 17 00:00:00 2001 From: jurki Date: Thu, 25 Jan 2024 13:29:39 +0100 Subject: [PATCH 1/3] debug connection url --- src/QueueConnection.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/QueueConnection.js b/src/QueueConnection.js index cb153ba..dde5b8c 100644 --- a/src/QueueConnection.js +++ b/src/QueueConnection.js @@ -53,7 +53,7 @@ class QueueConnection extends EventEmitter { this._connection = connection return connection }).catch((err) => { - this._logger.error('RabbitMQ connection failed', err) + this._logger.error('RabbitMQ connection failed', this._config.url, err) throw err }) From 6cf48ecc4739908fd4d319ee98ddd82ba4fdc868 Mon Sep 17 00:00:00 2001 From: jurki Date: Thu, 25 Jan 2024 14:32:07 +0100 Subject: [PATCH 2/3] fix --- src/QueueConnection.js | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/QueueConnection.js b/src/QueueConnection.js index dde5b8c..93c3766 100644 --- a/src/QueueConnection.js +++ b/src/QueueConnection.js @@ -53,7 +53,7 @@ class QueueConnection extends EventEmitter { this._connection = connection return connection }).catch((err) => { - this._logger.error('RabbitMQ connection failed', this._config.url, err) + this._logger.error('RabbitMQ connection failed', err) throw err }) @@ -108,9 +108,14 @@ class QueueConnection extends EventEmitter { // assume simple url string or standard url object const connectionUrl = QueueConfig.urlStringToObject(configUrl) - const connection = await amqp.connect(configUrl, options) - this._activeConnectionConfig = connectionUrl - return connection + try{ + const connection = await amqp.connect(configUrl, options) + this._activeConnectionConfig = connectionUrl + return connection + } catch (error) { + this._logger.error('RabbitMQ connection failed to host:', { ...connectionUrl, password: connectionUrl.password ? '***' : connectionUrl.password }) + throw new Error('RabbitMQ connection failed with single url') + } } async _connectWithMultipleUrls (urls, options) { From d5327c28a3e59a5f7b2dc130c31fc5519029ffcf Mon Sep 17 00:00:00 2001 From: jurki Date: Tue, 14 May 2024 10:21:11 +0200 Subject: [PATCH 3/3] requested changes --- src/QueueConnection.js | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-) diff --git a/src/QueueConnection.js b/src/QueueConnection.js index 93c3766..91b0193 100644 --- a/src/QueueConnection.js +++ b/src/QueueConnection.js @@ -101,21 +101,10 @@ class QueueConnection extends EventEmitter { configUrl = urls } - // handle multiple connection urls - if (Array.isArray(configUrl)) { - return this._connectWithMultipleUrls(configUrl, options) - } - - // assume simple url string or standard url object - const connectionUrl = QueueConfig.urlStringToObject(configUrl) - try{ - const connection = await amqp.connect(configUrl, options) - this._activeConnectionConfig = connectionUrl - return connection - } catch (error) { - this._logger.error('RabbitMQ connection failed to host:', { ...connectionUrl, password: connectionUrl.password ? '***' : connectionUrl.password }) - throw new Error('RabbitMQ connection failed with single url') + if (!Array.isArray(configUrl)) { + configUrl = [configUrl] } + return this._connectWithMultipleUrls(configUrl, options) } async _connectWithMultipleUrls (urls, options) {