Robert Quinlivan created KAFKA-4854:
---------------------------------------

             Summary: 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
            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
(v6.3.15#6346)

Reply via email to