feat(RabbitMQ Trigger Node): Add exchange and routing key options (#7547)

RabbitMQ trigger needs binding for some cases. For example, I need to
consume some domain events in my application and they are published with
routing key.

---------

Co-authored-by: teomane <emre.teoman@bordatech.com>
This commit is contained in:
EMRE TEOMAN 2023-11-15 14:02:54 +03:00 committed by GitHub
parent 27cb7c3c63
commit 5aee2b768f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 46 additions and 0 deletions

View file

@ -76,6 +76,19 @@ export async function rabbitmqConnectQueue(
return new Promise(async (resolve, reject) => {
try {
await channel.assertQueue(queue, options);
if (options.binding && ((options.binding as IDataObject).bindings! as IDataObject[]).length) {
((options.binding as IDataObject).bindings as IDataObject[]).forEach(
async (binding: IDataObject) => {
await channel.bindQueue(
queue,
binding.exchange as string,
binding.routingKey as string,
);
},
);
}
resolve(channel);
} catch (error) {
reject(error);

View file

@ -139,6 +139,39 @@ export class RabbitMQTrigger implements INodeType {
},
description: 'Max number of executions at a time. Use -1 for no limit.',
},
{
displayName: 'Binding',
name: 'binding',
placeholder: 'Add Binding',
description: 'Add binding to queu',
type: 'fixedCollection',
typeOptions: {
multipleValues: true,
},
default: {},
options: [
{
name: 'bindings',
displayName: 'Binding',
values: [
{
displayName: 'Exchange',
name: 'exchange',
type: 'string',
default: '',
placeholder: 'exchange',
},
{
displayName: 'RoutingKey',
name: 'routingKey',
type: 'string',
default: '',
placeholder: 'routing-key',
},
],
},
],
},
...rabbitDefaultOptions,
].sort((a, b) => {
if (