This is an automated email from the ASF dual-hosted git repository. davsclaus pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/main by this push: new 7ef97ad Adding a sample to topicIsPattern consuming option (#5821) 7ef97ad is described below commit 7ef97add9e80005162467beb9b2081ff0e982fd4 Author: Marcelo Avancini <marcelo.a...@gmail.com> AuthorDate: Fri Jul 9 15:05:57 2021 -0300 Adding a sample to topicIsPattern consuming option (#5821) --- components/camel-kafka/src/main/docs/kafka-component.adoc | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/components/camel-kafka/src/main/docs/kafka-component.adoc b/components/camel-kafka/src/main/docs/kafka-component.adoc index 940e9b7..92fd0db 100644 --- a/components/camel-kafka/src/main/docs/kafka-component.adoc +++ b/components/camel-kafka/src/main/docs/kafka-component.adoc @@ -368,7 +368,7 @@ from("kafka:test?brokers=localhost:9092") .log(" with the key ${headers[kafka.KEY]}") ---- -If you need to consume messages from multiple topics you can use a comma separated list of topic names +If you need to consume messages from multiple topics you can use a comma separated list of topic names. [source,java] ---- @@ -380,6 +380,18 @@ from("kafka:test,test1,test2?brokers=localhost:9092") .log(" with the key ${headers[kafka.KEY]}") ---- +It's also possible to subscribe to multiple topics giving a pattern as the topic name and using the `topicIsPattern` option. + +[source,java] +---- +from("kafka:test*?brokers=localhost:9092&topicIsPattern=true") + .log("Message received from Kafka : ${body}") + .log(" on the topic ${headers[kafka.TOPIC]}") + .log(" on the partition ${headers[kafka.PARTITION]}") + .log(" with the offset ${headers[kafka.OFFSET]}") + .log(" with the key ${headers[kafka.KEY]}") +---- + When consuming messages from Kafka you can use your own offset management and not delegate this management to Kafka. In order to keep the offsets the component needs a `StateRepository` implementation such as `FileStateRepository`. This bean should be available in the registry.