Skip to content

Commit

Permalink
GH-1673: Improve Docs for Default @KafkaHandler
Browse files Browse the repository at this point in the history
Resolves #1673

**cherry-pick to 2.6.x, 2.5.x**
  • Loading branch information
garyrussell authored and artembilan committed Jan 11, 2021
1 parent 23c0957 commit c54d4f5
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/reference/asciidoc/kafka.adoc
Expand Up @@ -1686,7 +1686,18 @@ public void listenDefault(Object object, @Header(KafkaHeaders.RECEIVED_TOPIC) St

This won't work if the object is a `String`; the `topic` parameter will also get a reference to `object`.

If you need metadata about the record in a default method, use this
If you need metadata about the record in a default method, use this:

====
[source, java]
----
@KafkaHandler(isDefault = true)
void listen(Object in, @Header(KafkaHeaders.RECORD_METADATA) ConsumerRecordMetadata meta) {
String topic = meta.topic();
...
}
----
====

[[kafkalistener-lifecycle]]
===== `@KafkaListener` Lifecycle Management
Expand Down

0 comments on commit c54d4f5

Please sign in to comment.