How to change client config in kafkajs

Viewed 42

As described in a doc https://kafka.js.org/docs/configuration the client must be configured with at least one broker.

const { Kafka } = require('kafkajs')

let kafka = new Kafka({
  clientId: 'my-app',
  brokers: ['kafka1:9092', 'kafka2:9092']
})

With kafka client initiated I want to go ahead and update its ssl settings. Is there a way to update kafka client by specifying its ssl values or I would need to re-declare the kafka variable, like so:

kafka = new Kafka({
  clientId: 'my-app',
  brokers: ['kafka1:9092', 'kafka2:9092'],
  // authenticationTimeout: 10000,
  // reauthenticationThreshold: 10000,
  ssl: true,
  sasl: {
    mechanism: 'plain',
    username: 'my-username',
    password: 'my-password'
  },
})
0 Answers
Related