cbickel closed pull request #4080: Catch kafka producer exceptions and recreate
the producer
URL: https://github.com/apache/incubator-openwhisk/pull/4080
This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:
As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):
diff --git
a/common/scala/src/main/scala/whisk/connector/kafka/KafkaProducerConnector.scala
b/common/scala/src/main/scala/whisk/connector/kafka/KafkaProducerConnector.scala
index bda2a114b8..7af5c187fe 100644
---
a/common/scala/src/main/scala/whisk/connector/kafka/KafkaProducerConnector.scala
+++
b/common/scala/src/main/scala/whisk/connector/kafka/KafkaProducerConnector.scala
@@ -55,12 +55,17 @@ class KafkaProducerConnector(
Future {
blocking {
- producer.send(record, new Callback {
- override def onCompletion(metadata: RecordMetadata, exception:
Exception): Unit = {
- if (exception == null) produced.success(metadata)
- else produced.failure(exception)
- }
- })
+ try {
+ producer.send(record, new Callback {
+ override def onCompletion(metadata: RecordMetadata, exception:
Exception): Unit = {
+ if (exception == null) produced.trySuccess(metadata)
+ else produced.tryFailure(exception)
+ }
+ })
+ } catch {
+ case e: Throwable =>
+ produced.tryFailure(e)
+ }
}
}
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services