0

I am using the KafkaJS to create the topics.

 const kafka = new Kafka({

  connectionTimeout: 10_000,
  authenticationTimeout: 10_000,
  brokers: [`HOST_NAME:9092`],
  clientId: 'example-producer',
  ssl: {
    servername: 'HOST_NAME',
    rejectUnauthorized: false
  },
  sasl: {
    mechanism: 'plain',
    username: '*******',
    password: '******'
  }
})

const admin = kafka.admin();
await admin.connect()

const topic = 'test-topics';
const run = async () => {
  await admin.connect()
  await admin.createTopics({
    topics: [{ topic }],
    waitForLeaders: true,
  })
  await admin.createPartitions({
    topicPartitions: [{ topic: topic, count: 1}],
  })
}
run().catch(e => kafka.logger().error(`[Kafka-config] ${e.message}`, { stack: e.stack }));

Getting below error:

message":"[Connection] Response CreateTopics(key: 19, version: 3)","broker":"HOST_NAME:9092","clientId":"example-producer","error":"Request parameters do not satisfy the configured policy","correlationId":3,"size":58}

But when I tried to list the topic present in the cluster I am getting successful responses as Topic already exist.

OneCricketeer
  • 179,855
  • 19
  • 132
  • 245
user1912
  • 35
  • 1
  • 8

1 Answers1

2

Adding topics: [{ topic **,replicationFactor: 3**}] resolved the issue

user1912
  • 35
  • 1
  • 8