When producing message to Kafka you can get two kind of errors: retriables and non-retriables. How should you differentiate them when handling them?
I want to produce records asynchronously, saving in another topic (or HBase) those in which callback object
receives a nonretriable exception and let the producer handle for me all those that receives a retriable exception (up to a maximum number of attempts and, when it finally reach it, becomes one of the first ones).
My question is: will the producer still handle the retrievable exceptions by itself despite the callback object
?
Because in the Interface Callback says:
Retriable exceptions (transient, may be covered by increasing # .retries)
Could be the code something like this?
producer.send(record, callback)
def callback: Callback = new Callback {
override def onCompletion(recordMetadata: RecordMetadata, e: Exception): Unit = {
if(null != e) {
if (e == RecordTooLargeException || e == UnknownServerException || ..) {
log.error("Winter is comming")
writeDiscardRecordsToSomewhereElse
} else {
log.warn("It's no that cold") //it's retriable. The producer will keep trying by itself?
}
} else {
log.debug("It's summer. Everything is fine")
}
}
}
Kafka version: 0.10.0
Any light will be appreciated! :)