@@ -80,10 +80,37 @@ public void listen(String data) {
8080}
8181----
8282
83- [[manual -assignment]]
84- == Explicit Partition Assignment
83+ [[topic-partition -assignment]]
84+ == Topic Partition Assignment
8585
86- You can also configure POJO listeners with explicit topics and partitions (and, optionally, their initial offsets).
86+ You can configure the topic for `@KafkaListener` in three ways.
87+ You must configure the topic in one of these ways.
88+ [source, java]
89+ ----
90+ @KafkaListener(id = "myListener", topics = "myTopic")
91+ public void listen(String data) {
92+ ...
93+ }
94+
95+ @KafkaListener(id = "myListener", topicPattern = "my.*")
96+ public void listen(String data) {
97+ ...
98+ }
99+
100+ @KafkaListener(id = "myListener", topicPartitions = { @TopicPartition(topic = "myTopic", partitions = { "0", "1" })})
101+ public void listen(String data) {
102+ ...
103+ }
104+ ----
105+
106+
107+ You can simply configure the topic directly by name.
108+ In this case, you can also configure the multiple topics like `topics = {"myTopic1", myTopic2"}`.
109+
110+ You can also configure topics using topicPattern, which enables topic subscription based on a regular expression.
111+
112+ When you configure topics using either of these ways (topic or topic pattern), Kafka automatically assigns partitions according to the consumer group.
113+ Alternatively, you can configure POJO listeners with explicit topics and partitions (and, optionally, their initial offsets).
87114The following example shows how to do so:
88115
89116[source, java]
0 commit comments