If one of the messages in the messages array fails to be produced in the Kafka topic then will it also prevent other messages to be produced?
const producer = kafka.producer()
await producer.connect()
await producer.send({
topic: 'topic-name',
messages: [
{ key: 'key1', value: 'hello world' },
{ key: 'key2', value: 'hey hey!' }
],
})
No, it won't prevent other messages from being produced. In particular if the messages go to other partitions/brokers.
For example, imagine 3 brokers and 3 partitions. A producer could send one message to each broker, and maybe one comes back as failed due to a network connection issues. I'm not sure if the JS driver does a internal batching (like the java client), which could also create other situations in which some messages are produced while others fail even if they go to the same partition.
If you need all or nothing semantics, KafkaJS supports transactions.