You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2018/08/16 07:14:07 UTC
[camel] branch apache-master updated: Update kafka-component.adoc
(#2474)
This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch apache-master
in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/apache-master by this push:
new f3e4026 Update kafka-component.adoc (#2474)
f3e4026 is described below
commit f3e4026cad08f13cf30e084643b7b9d673b02f00
Author: elbaz michael <mi...@outlook.fr>
AuthorDate: Thu Aug 16 09:14:03 2018 +0200
Update kafka-component.adoc (#2474)
* Update kafka-component.adoc
* Improve the spring example
Add @PostConstruct method
* Improve Spring Example
using initMethod and destroyMethod @Bean(name = "offsetRepo", initMethod = "start", destroyMethod = "stop")
---
.../camel-kafka/src/main/docs/kafka-component.adoc | 20 ++++++++++++++++++++
1 file changed, 20 insertions(+)
diff --git a/components/camel-kafka/src/main/docs/kafka-component.adoc b/components/camel-kafka/src/main/docs/kafka-component.adoc
index 4604e9c..949f36a 100644
--- a/components/camel-kafka/src/main/docs/kafka-component.adoc
+++ b/components/camel-kafka/src/main/docs/kafka-component.adoc
@@ -236,6 +236,26 @@ camelContext.addRoutes(new RouteBuilder() {
}
});
----------------------------------------------------------------------------------------------------------------------------
+[source,java]
+----------------------------------------------------------------------------------------------------------------------------
+// Create the repository in which the Kafka offsets will be persisted using Spring @Bean annotation
+@Bean(name = "offsetRepo", initMethod = "start", destroyMethod = "stop")
+private FileStateRepository fileStateRepository() {
+ FileStateRepository fileStateRepository = FileStateRepository.fileStateRepository(new File("/path/to/repo.dat"));
+ return fileStateRepository;
+}
+
+camelContext.addRoutes(new RouteBuilder() {
+ @Override
+ public void configure() throws Exception {
+ from("kafka:" + TOPIC + "?brokers=localhost:{{kafkaPort}}" +
+ "&groupId=A" + //
+ "&autoOffsetReset=earliest" + // Ask to start from the beginning if we have unknown offset
+ "&offsetRepository=#offsetRepo") // Keep the offsets in the previously configured repository
+ .to("mock:result");
+ }
+});
+----------------------------------------------------------------------------------------------------------------------------
#### Producing messages to Kafka