[ https://issues.apache.org/jira/browse/KAFKA-6744?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16427053#comment-16427053 ]
Sönke Liebau commented on KAFKA-6744: ------------------------------------- I don't think this functionality has been added to the MockProducer yet. Looking at the [errorNext|https://github.com/apache/kafka/blob/trunk/clients/src/main/java/org/apache/kafka/clients/producer/MockProducer.java#L394] and [Completion.complete|https://github.com/apache/kafka/blob/trunk/clients/src/main/java/org/apache/kafka/clients/producer/MockProducer.java#L442] functions I think that currently only the callbacks are called with the exception, but after that it is discarded. Are you interested in creating a PR for this? > MockProducer with transaction enabled doesn't fail on commit if a record was > failed > ----------------------------------------------------------------------------------- > > Key: KAFKA-6744 > URL: https://issues.apache.org/jira/browse/KAFKA-6744 > Project: Kafka > Issue Type: Bug > Components: producer > Affects Versions: 1.0.0 > Reporter: Pascal Gélinas > Priority: Minor > > The KafkaProducer#send documentation states the following: > When used as part of a transaction, it is not necessary to define a callback > or check the result of the future in order to detect errors from send. If any > of the send calls failed with an irrecoverable error, the final > commitTransaction() call will fail and throw the exception from the last > failed send. > So I was expecting the following to throw an exception: > {{*MockProducer*<String, byte[]> producer = new MockProducer<>(false,}} > {{ new StringSerializer(), new ByteArraySerializer());}} > {{producer.initTransactions();}} > {{producer.beginTransaction();}} > {{producer.send(new ProducerRecord<>("foo", new byte[]{}));}} > {{producer.errorNext(new RuntimeException());}} > {{producer.commitTransaction(); // Expecting this to throw}} > Unfortunately, the commitTransaction() call returns successfully. -- This message was sent by Atlassian JIRA (v7.6.3#76005)