|
|
@ -27,20 +27,10 @@ let kafkaAdmin; |
|
|
let consumer; |
|
|
let consumer; |
|
|
let producer; |
|
|
let producer; |
|
|
|
|
|
|
|
|
const topics = []; |
|
|
|
|
|
const configEntries = []; |
|
|
const configEntries = []; |
|
|
|
|
|
|
|
|
function KafkaProducer() { |
|
|
function KafkaProducer() { |
|
|
this.send = async (responseTopic, scriptId, rawResponse, headers) => { |
|
|
this.send = async (responseTopic, scriptId, rawResponse, headers) => { |
|
|
|
|
|
|
|
|
if (!topics.includes(responseTopic)) { |
|
|
|
|
|
let createResponseTopicResult = await createTopic(responseTopic, 1); |
|
|
|
|
|
topics.push(responseTopic); |
|
|
|
|
|
if (createResponseTopicResult) { |
|
|
|
|
|
logger.info('Created new topic: %s', requestTopic); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return producer.send( |
|
|
return producer.send( |
|
|
{ |
|
|
{ |
|
|
topic: responseTopic, |
|
|
topic: responseTopic, |
|
|
@ -99,10 +89,13 @@ function KafkaProducer() { |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
let createRequestTopicResult = await createTopic(requestTopic, partitions); |
|
|
let topics = await kafkaAdmin.listTopics(); |
|
|
|
|
|
|
|
|
if (createRequestTopicResult) { |
|
|
if (!topics.includes(requestTopic)) { |
|
|
logger.info('Created new topic: %s', requestTopic); |
|
|
let createRequestTopicResult = await createTopic(requestTopic, partitions); |
|
|
|
|
|
if (createRequestTopicResult) { |
|
|
|
|
|
logger.info('Created new topic: %s', requestTopic); |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
consumer = kafkaClient.consumer({groupId: 'js-executor-group'}); |
|
|
consumer = kafkaClient.consumer({groupId: 'js-executor-group'}); |
|
|
|