Skip to content

Commit

Permalink
feat(RabbitMQ Trigger Node): Add options to configure assert of excha…
Browse files Browse the repository at this point in the history
…nges and queues (#8430)
  • Loading branch information
ascariandrea authored Feb 2, 2024
1 parent ee5e422 commit 4b3659f
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
14 changes: 14 additions & 0 deletions packages/nodes-base/nodes/RabbitMQ/DefaultOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
12 changes: 10 additions & 2 deletions packages/nodes-base/nodes/RabbitMQ/GenericFunctions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 4b3659f

Please sign in to comment.