From 1811c54917e5940a3f170761c94096845319db28 Mon Sep 17 00:00:00 2001 From: Jakob Backlund Date: Wed, 12 Oct 2022 17:57:05 +0300 Subject: [PATCH] feat(Kafka Node): add key option for messages (#4210) --- packages/nodes-base/nodes/Kafka/Kafka.node.ts | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/packages/nodes-base/nodes/Kafka/Kafka.node.ts b/packages/nodes-base/nodes/Kafka/Kafka.node.ts index 15f3327367..45a6a1ffa7 100644 --- a/packages/nodes-base/nodes/Kafka/Kafka.node.ts +++ b/packages/nodes-base/nodes/Kafka/Kafka.node.ts @@ -97,6 +97,27 @@ export class Kafka implements INodeType { default: '', description: 'URL of the schema registry', }, + { + displayName: 'Use Key', + name: 'useKey', + type: 'boolean', + default: false, + description: 'Whether to use a message key', + }, + { + displayName: 'Key', + name: 'key', + type: 'string', + required: true, + displayOptions: { + show: { + useKey: [true], + }, + }, + placeholder: '', + default: '', + description: 'The message key', + }, { displayName: 'Event Name', name: 'eventName', @@ -331,6 +352,10 @@ export class Kafka implements INodeType { const jsonParameters = this.getNodeParameter('jsonParameters', i) as boolean; + const useKey = this.getNodeParameter('useKey', i) as boolean; + + const key = useKey ? (this.getNodeParameter('key', i) as string) : null; + let headers; if (jsonParameters === true) { @@ -358,6 +383,7 @@ export class Kafka implements INodeType { { value: message, headers, + key, }, ], });