Skip to content

Commit

Permalink
feat(Kafka Node): add key option for messages (n8n-io#4210)
Browse files Browse the repository at this point in the history
  • Loading branch information
jbacklund authored Oct 12, 2022
1 parent 006c5a6 commit 9ffa669
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions packages/nodes-base/nodes/Kafka/Kafka.node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -358,6 +383,7 @@ export class Kafka implements INodeType {
{
value: message,
headers,
key,
},
],
});
Expand Down

0 comments on commit 9ffa669

Please sign in to comment.