Idempotency at the producer level

Am confused where to set this producer.send()

Sorry. Not sure what you mean.

Btw: in general, it your producer-app crashed, it’s tricky not to introduce duplicates in genearl.

Okay tell me one thing how to avoid that round robin thing

Using Kafka transaction can help, but it’s hard to get the code right.

Like when server crash or some tech issue

If my message go and sits in another partition

Now I tried passing key I’d which is 16digit alpha numeric

But that doesn’t help

I think there shud be masking for this key I’d

The producer allows you to configure the used partitioner via partitioner.class. All built-in partitioners use the message key to pick a partition (or round-robing if key=null). Thus, you can either set a message key, or if you want to pick a partition based on the value, you can implement you own partitioner.

You can also “skip” the partitioner, by setting the target partition expliclity when creating the ProducerRecord (you can pass in target partitioned into the constructor).

Cf https://kafka.apache.org/28/javadoc/org/apache/kafka/clients/producer/package-summary.html

Sure thanks a ton :slightly_smiling_face: