Skip to content

Commit c54d4f5

Browse files
garyrussellartembilan
authored andcommitted
GH-1673: Improve Docs for Default @KafkaHandler
Resolves #1673 **cherry-pick to 2.6.x, 2.5.x**
1 parent 23c0957 commit c54d4f5

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

src/reference/asciidoc/kafka.adoc

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1686,7 +1686,18 @@ public void listenDefault(Object object, @Header(KafkaHeaders.RECEIVED_TOPIC) St
16861686

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

1689-
If you need metadata about the record in a default method, use this
1689+
If you need metadata about the record in a default method, use this:
1690+
1691+
====
1692+
[source, java]
1693+
----
1694+
@KafkaHandler(isDefault = true)
1695+
void listen(Object in, @Header(KafkaHeaders.RECORD_METADATA) ConsumerRecordMetadata meta) {
1696+
String topic = meta.topic();
1697+
...
1698+
}
1699+
----
1700+
====
16901701

16911702
[[kafkalistener-lifecycle]]
16921703
===== `@KafkaListener` Lifecycle Management

0 commit comments

Comments
 (0)