mirror of
https://github.com/n8n-io/n8n.git
synced 2024-11-10 14:44:05 -08:00
✨ Add RabbitMQ Header parameter (#1622)
* Add RabbitMQ Exchange's Header parameter * code refactoring * remove log
This commit is contained in:
parent
0c8afbb3cb
commit
51f066cbcd
|
@ -36,6 +36,37 @@ export const rabbitDefaultOptions: Array<INodePropertyOptions | INodeProperties
|
|||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
displayName: 'Headers',
|
||||
name: 'headers',
|
||||
placeholder: 'Add Header',
|
||||
description: 'Headers to add.',
|
||||
type: 'fixedCollection',
|
||||
typeOptions: {
|
||||
multipleValues: true,
|
||||
},
|
||||
default: {},
|
||||
options: [
|
||||
{
|
||||
name: 'header',
|
||||
displayName: 'Header',
|
||||
values: [
|
||||
{
|
||||
displayName: 'Key',
|
||||
name: 'key',
|
||||
type: 'string',
|
||||
default: '',
|
||||
},
|
||||
{
|
||||
displayName: 'Value',
|
||||
name: 'value',
|
||||
type: 'string',
|
||||
default: '',
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
displayName: 'Auto Delete',
|
||||
name: 'autoDelete',
|
||||
|
|
|
@ -208,6 +208,37 @@ export class RabbitMQ implements INodeType {
|
|||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
displayName: 'Headers',
|
||||
name: 'headers',
|
||||
placeholder: 'Add Header',
|
||||
description: 'Headers to add.',
|
||||
type: 'fixedCollection',
|
||||
typeOptions: {
|
||||
multipleValues: true,
|
||||
},
|
||||
default: {},
|
||||
options: [
|
||||
{
|
||||
name: 'header',
|
||||
displayName: 'Header',
|
||||
values: [
|
||||
{
|
||||
displayName: 'Key',
|
||||
name: 'key',
|
||||
type: 'string',
|
||||
default: '',
|
||||
},
|
||||
{
|
||||
displayName: 'Value',
|
||||
name: 'value',
|
||||
type: 'string',
|
||||
default: '',
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
displayName: 'Auto Delete',
|
||||
name: 'autoDelete',
|
||||
|
@ -322,6 +353,15 @@ export class RabbitMQ implements INodeType {
|
|||
|
||||
const options = this.getNodeParameter('options', 0, {}) as IDataObject;
|
||||
|
||||
let headers : IDataObject = {};
|
||||
if (options.headers && ((options.headers as IDataObject).header! as IDataObject[]).length) {
|
||||
const additionalHeaders: IDataObject = {};
|
||||
((options.headers as IDataObject).header as IDataObject[]).forEach((header: IDataObject) => {
|
||||
additionalHeaders[header.key as string] = header.value;
|
||||
});
|
||||
headers = additionalHeaders;
|
||||
}
|
||||
|
||||
channel = await rabbitmqConnectExchange.call(this, exchange, type, options);
|
||||
|
||||
const sendInputData = this.getNodeParameter('sendInputData', 0) as boolean;
|
||||
|
@ -336,7 +376,7 @@ export class RabbitMQ implements INodeType {
|
|||
message = this.getNodeParameter('message', i) as string;
|
||||
}
|
||||
|
||||
exchangePromises.push(channel.publish(exchange, routingKey, Buffer.from(message)));
|
||||
exchangePromises.push(channel.publish(exchange, routingKey, Buffer.from(message), {headers}));
|
||||
}
|
||||
|
||||
// @ts-ignore
|
||||
|
|
Loading…
Reference in a new issue