Kafka producer failed to write

I am using Alpakka Kafka Producer flow and I want a way to see if the message was produced successfully or failed while writing to Kafka and I want to pass this info in downstream. Based on the success/fail value I want to write the custom logic. Can someone please help!

Hi @architmmmec

Alpakka Kafka producers do not support emitting success/failure, a producer failure will cancel the stream.
See Kafka - Ability to react on message publication result for a more detailed discussion.


If exception is “kafka.network.exception” or “kafka.timeout.exception” then we can recover that element?

@ennru, My use case is I want to write to buffer those events which were not written successfully in Kafka and Kafka will again try to write those events. But thing is I am not able to filter elements which were written successfully or failed because it is a stream and as soon as exception comes it goes to Actor’s supervision decider from where stream was called. I tried adding recover in a stream but couldn’t achieve it,

That is not easily possible with the current Alpakka Kafka API.
https://github.com/akka/alpakka-kafka/issues/1101 suggests to add support for it.