== Camel Kafka - Spring Boot example

=== Abstract

An example which shows how to integrate Camel with Kafka offsetRepository to use in order to locally store the offset of each partition of the topic

=== Introduction

This project consists of the following examples:

  1. Producer triggers with a timer and produces messages to the configured topic
  2. Consumer consumes from configured topic by reading the offset value from locally stored file.

== Trying out the example on your local machine

Start the kafka broker:

----
docker run -d -e ALLOW_PLAINTEXT_LISTENER=yes -e KAFKA_CFG_ADVERTISED_LISTENERS=PLAINTEXT://localhost:9092 -e KAFKA_CFG_AUTO_CREATE_TOPICS_ENABLE=true -p 9092:9092 bitnami/kafka:latest
----

=== How to run the example

You can run this example using

    mvn spring-boot:run

You can then examine the newly created file `offsetStateRepo.dat` to see the topic offset:

----
offset-repo-example/0=0
offset-repo-example/0=1
offset-repo-example/0=2
offset-repo-example/0=3
offset-repo-example/0=4
offset-repo-example/0=5
----

== Trying out the example on OpenShift

First, start with creating a new OpenShift project:

----
oc new-project csb-example-kafka-offset
----

Deploy Kafka using OperatorHub:

----
oc process -f src/main/resources/openshift/kafka-template.yml -p STARTING_CSV=$(oc get packagemanifests strimzi-kafka-operator -o jsonpath='{.status.channels[?(@.name=="stable")].currentCSV}') | oc create -f -
----

=== How to run

The application is deployed using the `openshift-maven-plugin` that takes care of creating all the necessary OpenShift resources.

Simply use the following command to deploy the application:

----
mvn clean package -Popenshift
----

and wait until application pod reaches the `Ready` state. You can then access the `offsetStateRepo.dat` file for example with:

----
oc exec dc/camel-example-spring-boot-kafka-offsetrepository -- cat /deployments/offsetStateRepo.dat
----

=== Help and contributions

If you hit any problem using Camel or have some feedback, 
then please https://camel.apache.org/support.html[let us know].

We also love contributors, 
so https://camel.apache.org/contributing.html[get involved] :-)

The Camel riders!
