feat(RabbitMQ Trigger Node): Add options to configure assert of exchanges and queues (#8430)

This commit is contained in:
Andrea Ascari 2024-02-02 16:02:09 +01:00 committed by GitHub
parent ee5e422094
commit 4b3659f04f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 24 additions and 2 deletions

View file

@ -72,6 +72,20 @@ export const rabbitDefaultOptions: Array<
default: false, default: false,
description: 'Whether the queue will be deleted when the number of consumers drops to zero', 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', displayName: 'Durable',
name: 'durable', name: 'durable',

View file

@ -75,7 +75,11 @@ export async function rabbitmqConnectQueue(
return await new Promise(async (resolve, reject) => { return await new Promise(async (resolve, reject) => {
try { 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) { if (options.binding && ((options.binding as IDataObject).bindings! as IDataObject[]).length) {
((options.binding as IDataObject).bindings as IDataObject[]).forEach( ((options.binding as IDataObject).bindings as IDataObject[]).forEach(
@ -106,7 +110,11 @@ export async function rabbitmqConnectExchange(
return await new Promise(async (resolve, reject) => { return await new Promise(async (resolve, reject) => {
try { try {
await channel.assertExchange(exchange, type, options); if (options.assertExchange) {
await channel.assertExchange(exchange, type, options);
} else {
await channel.checkExchange(exchange);
}
resolve(channel); resolve(channel);
} catch (error) { } catch (error) {
reject(error); reject(error);