The KafkaProducer.initTransactions() by default rolls back the transaction with the same transactional.id. I need an ability to commit such a transaction. I'm using Kafka as a part of a two-phase commit and if all participants voted "yes" in the pre-commit phase and the Kafka producer crashed after the coordinator made the decision, I need to commit the transaction after the Kafka producer is brought back again. Otherwise some participating transactions could be committed and some not.
I found this code in Apache Flink doing that: https://github.com/apache/flink/blob/c7bf460b15ff1501f1d0ffa24ad5a074032bc503/flink-connectors/flink-connector-kafka/src/main/java/org/apache/flink/streaming/connectors/kafka/internal/FlinkKafkaInternalProducer.java#L138-L164 But it looks too hacky and it's unsupported and fragile. Is there a chance of having this feature officially supported? I already sent this question to kafka-users but got no response. Viliam