Skip to content

Commit

Permalink
KAFKA-7412: clarify the doc for producer callback (apache#5798)
Browse files Browse the repository at this point in the history
The metadata in the callback is not null with non-null exception.

Reviewers: Jun Rao <[email protected]>
  • Loading branch information
huxihx authored and junrao committed Nov 9, 2018
1 parent eb3335e commit 895c83f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,11 @@ public interface Callback {

/**
* A callback method the user can implement to provide asynchronous handling of request completion. This method will
* be called when the record sent to the server has been acknowledged. Exactly one of the arguments will be
* non-null.
* @param metadata The metadata for the record that was sent (i.e. the partition and offset). Null if an error
* occurred.
* be called when the record sent to the server has been acknowledged. When exception is not null in the callback,
* metadata will contain the special -1 value for all fields except for topicPartition, which will be valid.
*
* @param metadata The metadata for the record that was sent (i.e. the partition and offset). An empty metadata
* with -1 value for all fields except for topicPartition will be returned if an error occurred.
* @param exception The exception thrown during processing of this record. Null if no error occurred.
* Possible thrown exceptions include:
*
Expand All @@ -49,5 +50,5 @@ public interface Callback {
* TimeoutException
* UnknownTopicOrPartitionException
*/
public void onCompletion(RecordMetadata metadata, Exception exception);
void onCompletion(RecordMetadata metadata, Exception exception);
}
4 changes: 2 additions & 2 deletions examples/src/main/java/kafka/examples/Producer.java
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,8 @@ public DemoCallBack(long startTime, int key, String message) {

/**
* A callback method the user can implement to provide asynchronous handling of request completion. This method will
* be called when the record sent to the server has been acknowledged. Exactly one of the arguments will be
* non-null.
* be called when the record sent to the server has been acknowledged. When exception is not null in the callback,
* metadata will contain the special -1 value for all fields except for topicPartition, which will be valid.
*
* @param metadata The metadata for the record that was sent (i.e. the partition and offset). Null if an error
* occurred.
Expand Down

0 comments on commit 895c83f

Please sign in to comment.