From 47c53ceffc429f3b190e9df8cbdaeb6a2564b8dc Mon Sep 17 00:00:00 2001 From: benjamonnguyen Date: Tue, 24 Oct 2023 12:34:29 -0700 Subject: [PATCH 1/2] allow configuring optional queue arguments --- docs/plugins/queue/rabbitmq_amqplib.md | 6 ++++++ plugins/queue/rabbitmq_amqplib.js | 3 ++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/docs/plugins/queue/rabbitmq_amqplib.md b/docs/plugins/queue/rabbitmq_amqplib.md index c34fae13d..1633bc6c6 100644 --- a/docs/plugins/queue/rabbitmq_amqplib.md +++ b/docs/plugins/queue/rabbitmq_amqplib.md @@ -36,5 +36,11 @@ Configuration durable = true autoDelete = false + ; Optional queue arguments + [queue_args] + x-dead-letter-exchange = + x-dead-letter-routing-key = emails_dlq + x-overflow = reject-publish + x-queue-type = quorum More information about RabbitMQ can be found at https://www.rabbitmq.com/ diff --git a/plugins/queue/rabbitmq_amqplib.js b/plugins/queue/rabbitmq_amqplib.js index 8de3f3a7b..aab45543b 100644 --- a/plugins/queue/rabbitmq_amqplib.js +++ b/plugins/queue/rabbitmq_amqplib.js @@ -26,6 +26,7 @@ exports.rabbitmq_queue = function (next, connection) { exports.init_amqp_connection = function () { const cfg = this.config.get("rabbitmq.ini").rabbitmq; + const queueArgs = this.config.get("rabbitmq.ini").queue_args; const protocol = cfg.protocol || "amqp"; const host = cfg.host || "127.0.0.1"; @@ -58,7 +59,7 @@ exports.init_amqp_connection = function () { return conn.close(); } ch.assertQueue(queueName, - {durable, autoDelete}, + {durable, autoDelete, arguments: queueArgs}, (err4, ok2) => { if (err4) { this.logerror(`Error asserting rabbitmq queue: ${err4}`); From 5d3eae7e970214a579c33b154295fb2c8c04b512 Mon Sep 17 00:00:00 2001 From: benjamonnguyen Date: Tue, 24 Oct 2023 17:56:25 -0700 Subject: [PATCH 2/2] add more docs; make statement inline --- Changes.md | 1 + config/rabbitmq_amqplib.ini | 9 ++++++++- docs/plugins/queue/rabbitmq_amqplib.md | 1 + plugins/queue/rabbitmq_amqplib.js | 3 +-- 4 files changed, 11 insertions(+), 3 deletions(-) diff --git a/Changes.md b/Changes.md index b4b183aa3..c86c37fa8 100644 --- a/Changes.md +++ b/Changes.md @@ -2,6 +2,7 @@ ### Unreleased - dep(plugin-spf): bump version to 1.2.1 +- feat(rabbitmq_amqplib): configurable optional queue arguments ### [3.0.2] - 2023-06-12 diff --git a/config/rabbitmq_amqplib.ini b/config/rabbitmq_amqplib.ini index 5c08aaab7..b91a3b97e 100644 --- a/config/rabbitmq_amqplib.ini +++ b/config/rabbitmq_amqplib.ini @@ -9,4 +9,11 @@ queueName = emails deliveryMode = 2 confirm = true durable = true -autoDelete = false \ No newline at end of file +autoDelete = false + +; Optional queue arguments +; [queue_args] +; x-dead-letter-exchange = +; x-dead-letter-routing-key = emails_dlq +; x-overflow = reject-publish +; x-queue-type = quorum \ No newline at end of file diff --git a/docs/plugins/queue/rabbitmq_amqplib.md b/docs/plugins/queue/rabbitmq_amqplib.md index 1633bc6c6..ce1550368 100644 --- a/docs/plugins/queue/rabbitmq_amqplib.md +++ b/docs/plugins/queue/rabbitmq_amqplib.md @@ -37,6 +37,7 @@ Configuration autoDelete = false ; Optional queue arguments + ; More information about x-arguments can be found at https://www.rabbitmq.com/queues.html#optional-arguments [queue_args] x-dead-letter-exchange = x-dead-letter-routing-key = emails_dlq diff --git a/plugins/queue/rabbitmq_amqplib.js b/plugins/queue/rabbitmq_amqplib.js index aab45543b..58b2c9bb2 100644 --- a/plugins/queue/rabbitmq_amqplib.js +++ b/plugins/queue/rabbitmq_amqplib.js @@ -26,7 +26,6 @@ exports.rabbitmq_queue = function (next, connection) { exports.init_amqp_connection = function () { const cfg = this.config.get("rabbitmq.ini").rabbitmq; - const queueArgs = this.config.get("rabbitmq.ini").queue_args; const protocol = cfg.protocol || "amqp"; const host = cfg.host || "127.0.0.1"; @@ -59,7 +58,7 @@ exports.init_amqp_connection = function () { return conn.close(); } ch.assertQueue(queueName, - {durable, autoDelete, arguments: queueArgs}, + {durable, autoDelete, arguments: this.config.get("rabbitmq.ini").queue_args}, (err4, ok2) => { if (err4) { this.logerror(`Error asserting rabbitmq queue: ${err4}`);