blob: e3104bc34776bb44cda02f819156631da139f9f5 [file] [log] [blame]
== Kafka and Health Checks
This example shows how to run Camel connecting to a local Apache Kafka broker
and have Camel health-checks report status as either UP or DOWN depending
on stopping and starting the Kafka broker.
=== Running Kafka broker
You need Docker to run the local Kafka broker which can run via docker compose.
[source,sh]
----
$ docker-compose up -d
----
And then you can stop and start the broker to make Camel health check report
as either UP or DOWN.
[source,sh]
----
$ docker-compose stop
----
and to start it again
[source,sh]
----
$ docker-compose start
----
And to shutdown when you no longer need the broker.
[source,sh]
----
$ docker-compose down
----
=== Install JBang
First install JBang according to https://www.jbang.dev
When JBang is installed then you should be able to run from a shell:
[source,sh]
----
$ jbang --version
----
This will output the version of JBang.
To run this example you can either install Camel on JBang via:
[source,sh]
----
$ jbang app install camel@apache/camel
----
Which allows to run CamelJBang with `camel` as shown below.
=== How to run
Then you can run this example using:
[source,sh]
----
$ camel run consumer.yaml producer.yaml --health
----
And you can also run the example by using wildcards, instead of typing every file name:
[source,sh]
----
$ camel run * --health
----
You can also run consumer and producer in two seperate integrations:
[source,sh]
----
$ camel run consumer.yaml --health
----
[source,sh]
----
$ camel run producer.yaml --health
----
Then you can access `http://localhost:8080/q/health` from a web browser to see the health status.
Notice how you can check either the readiness or liveness health by invoking: `http://localhost:8080/q/health/live` and
`http://localhost:8080/q/health/ready`. When the kafka brokers are not running then the liveness check should still be UP but
readiness should be DOWN.
You can also quickly see the health check status when the Camel integration is running.
From another terminal execute:
[source,sh]
----
$ camel get health
----
=== Help and contributions
If you hit any problem using Camel or have some feedback, then please
https://camel.apache.org/community/support/[let us know].
We also love contributors, so
https://camel.apache.org/community/contributing/[get involved] :-)
The Camel riders!