[ 
https://issues.apache.org/jira/browse/KAFKA-4854?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Ewen Cheslack-Postava resolved KAFKA-4854.
------------------------------------------
    Resolution: Not A Bug
      Assignee: Ewen Cheslack-Postava

This behavior is intended. The idea is to have *either* valid metadata about 
the produced messages based on the successful reply from the broker *or* an 
exception indicating why production failed. Metadata about produced messages 
doesn't make sense in the case of an exception since the exception implies the 
messages were not successfully added to the log.

> Producer RecordBatch executes callbacks with `null` provided for metadata if 
> an exception is encountered
> --------------------------------------------------------------------------------------------------------
>
>                 Key: KAFKA-4854
>                 URL: https://issues.apache.org/jira/browse/KAFKA-4854
>             Project: Kafka
>          Issue Type: Bug
>          Components: producer 
>    Affects Versions: 0.10.1.1
>            Reporter: Robert Quinlivan
>            Assignee: Ewen Cheslack-Postava
>            Priority: Minor
>
> When using a user-provided callback with the producer, the `RecordBatch` 
> executes the callbacks with a null metadata argument if an exception was 
> encountered. For monitoring and debugging purposes, I would prefer if the 
> metadata were provided, perhaps optionally. For example, it would be useful 
> to know the size of the serialized payload and the offset so these values 
> could appear in application logs.
> To be entirely clear, the piece of code I am considering is in 
> `org.apache.kafka.clients.producer.internals.RecordBatch#done`:
> ```java
>         // execute callbacks
>         for (Thunk thunk : thunks) {
>             try {
>                 if (exception == null) {
>                     RecordMetadata metadata = thunk.future.value();
>                     thunk.callback.onCompletion(metadata, null);
>                 } else {
>                     thunk.callback.onCompletion(null, exception);
>                 }
>             } catch (Exception e) {
>                 log.error("Error executing user-provided callback on message 
> for topic-partition '{}'", topicPartition, e);
>             }
>         }
> ```



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to