mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 10:02:05 +00:00
fix(kafkaTrigger Node): fix kafka trigger not working with default max requests value
This commit is contained in:
@@ -11,7 +11,11 @@ import { SchemaRegistry } from '@kafkajs/confluent-schema-registry';
|
||||
import { IExecuteFunctions } from 'n8n-core';
|
||||
|
||||
import {
|
||||
ICredentialDataDecryptedObject,
|
||||
ICredentialsDecrypted,
|
||||
ICredentialTestFunctions,
|
||||
IDataObject,
|
||||
INodeCredentialTestResult,
|
||||
INodeExecutionData,
|
||||
INodeType,
|
||||
INodeTypeDescription,
|
||||
@@ -35,6 +39,7 @@ export class Kafka implements INodeType {
|
||||
{
|
||||
name: 'kafka',
|
||||
required: true,
|
||||
testedBy: 'kafkaConnectionTest',
|
||||
},
|
||||
],
|
||||
properties: [
|
||||
@@ -185,6 +190,56 @@ export class Kafka implements INodeType {
|
||||
],
|
||||
};
|
||||
|
||||
methods = {
|
||||
credentialTest: {
|
||||
async kafkaConnectionTest(
|
||||
this: ICredentialTestFunctions,
|
||||
credential: ICredentialsDecrypted,
|
||||
): Promise<INodeCredentialTestResult> {
|
||||
const credentials = credential.data as ICredentialDataDecryptedObject;
|
||||
try {
|
||||
const brokers = ((credentials.brokers as string) || '')
|
||||
.split(',')
|
||||
.map((item) => item.trim()) as string[];
|
||||
|
||||
const clientId = credentials.clientId as string;
|
||||
|
||||
const ssl = credentials.ssl as boolean;
|
||||
|
||||
const config: KafkaConfig = {
|
||||
clientId,
|
||||
brokers,
|
||||
ssl,
|
||||
};
|
||||
if (credentials.authentication === true) {
|
||||
if (!(credentials.username && credentials.password)) {
|
||||
throw Error('Username and password are required for authentication');
|
||||
}
|
||||
config.sasl = {
|
||||
username: credentials.username as string,
|
||||
password: credentials.password as string,
|
||||
mechanism: credentials.saslMechanism as string,
|
||||
} as SASLOptions;
|
||||
}
|
||||
|
||||
const kafka = new apacheKafka(config);
|
||||
|
||||
await kafka.admin().connect();
|
||||
await kafka.admin().disconnect();
|
||||
return {
|
||||
status: 'OK',
|
||||
message: 'Authentication successful',
|
||||
};
|
||||
} catch (error) {
|
||||
return {
|
||||
status: 'Error',
|
||||
message: error.message,
|
||||
};
|
||||
}
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
async execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]> {
|
||||
const items = this.getInputData();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user