|
|
|
@ -34,7 +34,7 @@ function KafkaProducer() { |
|
|
|
this.send = async (responseTopic, scriptId, rawResponse, headers) => { |
|
|
|
|
|
|
|
if (!topics.includes(responseTopic)) { |
|
|
|
let createResponseTopicResult = await createTopic(responseTopic); |
|
|
|
let createResponseTopicResult = await createTopic(responseTopic, 1); |
|
|
|
topics.push(responseTopic); |
|
|
|
if (createResponseTopicResult) { |
|
|
|
logger.info('Created new topic: %s', requestTopic); |
|
|
|
@ -88,7 +88,18 @@ function KafkaProducer() { |
|
|
|
kafkaAdmin = kafkaClient.admin(); |
|
|
|
await kafkaAdmin.connect(); |
|
|
|
|
|
|
|
let createRequestTopicResult = await createTopic(requestTopic); |
|
|
|
let partitions = 1; |
|
|
|
|
|
|
|
for (let i = 0; i < configEntries.length; i++) { |
|
|
|
let param = configEntries[i]; |
|
|
|
if (param.name === 'partitions') { |
|
|
|
partitions = param.value; |
|
|
|
configEntries.splice(i, 1); |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
let createRequestTopicResult = await createTopic(requestTopic, partitions); |
|
|
|
|
|
|
|
if (createRequestTopicResult) { |
|
|
|
logger.info('Created new topic: %s', requestTopic); |
|
|
|
@ -121,10 +132,11 @@ function KafkaProducer() { |
|
|
|
} |
|
|
|
})(); |
|
|
|
|
|
|
|
function createTopic(topic) { |
|
|
|
function createTopic(topic, partitions) { |
|
|
|
return kafkaAdmin.createTopics({ |
|
|
|
topics: [{ |
|
|
|
topic: topic, |
|
|
|
numPartitions: partitions, |
|
|
|
replicationFactor: replicationFactor, |
|
|
|
configEntries: configEntries |
|
|
|
}] |
|
|
|
|