From 4b3659f04f84ef774d31cf2341c5dbb500a73afe Mon Sep 17 00:00:00 2001 From: Andrea Ascari Date: Fri, 2 Feb 2024 16:02:09 +0100 Subject: [PATCH] feat(RabbitMQ Trigger Node): Add options to configure assert of exchanges and queues (#8430) --- .../nodes-base/nodes/RabbitMQ/DefaultOptions.ts | 14 ++++++++++++++ .../nodes-base/nodes/RabbitMQ/GenericFunctions.ts | 12 ++++++++++-- 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/packages/nodes-base/nodes/RabbitMQ/DefaultOptions.ts b/packages/nodes-base/nodes/RabbitMQ/DefaultOptions.ts index 17dcef42c8142..9533fb7f2f894 100644 --- a/packages/nodes-base/nodes/RabbitMQ/DefaultOptions.ts +++ b/packages/nodes-base/nodes/RabbitMQ/DefaultOptions.ts @@ -72,6 +72,20 @@ export const rabbitDefaultOptions: Array< default: false, description: 'Whether the queue will be deleted when the number of consumers drops to zero', }, + { + displayName: 'Assert Exchange', + name: 'assertExchange', + type: 'boolean', + default: true, + description: 'Whether to assert the exchange exists before sending', + }, + { + displayName: 'Assert Queue', + name: 'assertQueue', + type: 'boolean', + default: true, + description: 'Whether to assert the queue exists before sending', + }, { displayName: 'Durable', name: 'durable', diff --git a/packages/nodes-base/nodes/RabbitMQ/GenericFunctions.ts b/packages/nodes-base/nodes/RabbitMQ/GenericFunctions.ts index d98b8bd515c93..f85b20f078aa2 100644 --- a/packages/nodes-base/nodes/RabbitMQ/GenericFunctions.ts +++ b/packages/nodes-base/nodes/RabbitMQ/GenericFunctions.ts @@ -75,7 +75,11 @@ export async function rabbitmqConnectQueue( return await new Promise(async (resolve, reject) => { try { - await channel.assertQueue(queue, options); + if (options.assertQueue) { + await channel.assertQueue(queue, options); + } else { + await channel.checkQueue(queue); + } if (options.binding && ((options.binding as IDataObject).bindings! as IDataObject[]).length) { ((options.binding as IDataObject).bindings as IDataObject[]).forEach( @@ -106,7 +110,11 @@ export async function rabbitmqConnectExchange( return await new Promise(async (resolve, reject) => { try { - await channel.assertExchange(exchange, type, options); + if (options.assertExchange) { + await channel.assertExchange(exchange, type, options); + } else { + await channel.checkExchange(exchange); + } resolve(channel); } catch (error) { reject(error);