An example that shows how to create a Telegram bot using camel-quarkus, and how to produce and consume messages in a Kafka topic, and in postgesql database. It also shows how to set quickly a REST endpoint using platform-http. It also shows some implementations of Content Based Router EIP and Message Translator EIP.
The example application requires an existing Telegram bot, a running Kafka instance, and a running Postgresql instance. For simplicity, this example uses quarkus DevServices to launch a kafka instance, and a postgresql instance in dev mode.
You need to set the Telegram Token, and prod Kafka and postgresql instance credentials in the corresponding section in src/main/resources/application.properties
.
Set your telegram Token:
$ export TELEGRAM_AUTHORIZATION_TOKEN = <YOUR_TELEGRAM_AUTHORIZATION_TOKEN>
Run the application in development mode.
$ mvn clean compile quarkus:dev
Once you are done with developing you may want to package and run the application.
Important
|
Native mode requires having GraalVM and other tools installed. Please check the Prerequisites section of Camel Quarkus User guide. |
To prepare a native executable using GraalVM, run the following command:
$ mvn clean package -DskipTests -Pnative $ ./target/*-runner
You can build a container image for the application like this. Refer to the Quarkus Kubernetes guide for options around customizing image names, registries etc.
Uncomment the container build section. Set the proper image group.
$ mvn clean package -DskipTests
If you are using a local development cluster like Kind or k3s, you can use host the container image on your local host. Or, with minikube, use the Docker daemon from the cluster virtual machine eval $(minikube docker-env)
. Otherwise, you’ll need to push the image to a registry of your choosing.
Tip
|
You can build & deploy in one single step by doing mvn clean package -DskipTests -Dquarkus.kubernetes.deploy=true
|
Check pods are running.
Tail the application logs.
$ kubectl logs -f telegram-kafka-67ddc468d-z9kzt
To clean up do.
$ kubectl delete all -l app.kubernetes.io/name=telegram-kafkan