Skip to content

Commit e12e13a

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 adda0bf commit e12e13a

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
@@ -1769,7 +1769,18 @@ public void listenDefault(Object object, @Header(KafkaHeaders.RECEIVED_TOPIC) St
17691769

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

1772-
If you need metadata about the record in a default method, use this
1772+
If you need metadata about the record in a default method, use this:
1773+
1774+
====
1775+
[source, java]
1776+
----
1777+
@KafkaHandler(isDefault = true)
1778+
void listen(Object in, @Header(KafkaHeaders.RECORD_METADATA) ConsumerRecordMetadata meta) {
1779+
String topic = meta.topic();
1780+
...
1781+
}
1782+
----
1783+
====
17731784

17741785
[[kafkalistener-lifecycle]]
17751786
===== `@KafkaListener` Lifecycle Management

0 commit comments

Comments
 (0)