'Synchronous Kafka Producer - How to ensure a message was successfully delivered to kafka broker after future get method is called
try{
RecordMetadata d = producer.send(message).get()
if(d.hasoffset()){
//only way to ensure kafka was sent??
}}
catch (Exception e){
//or does this alone guarentee the message was sent
}
does the catch exception alone ensure the message was sent or is some if statement check required
Solution 1:[1]
You should set acks=1 or acks=all to ensure a broker gets the messages.
After that, then if .get() does not throw an exception, then the broker will have the record.
You'll also want to ensure the min.insync.replicas on the topics are at least 1.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | OneCricketeer |
