Todo Quarkus Kafka

API for TODO / Task management

En Java, avec Quarkus, Kafka, Hibernate et Panache

0) Could you share me the way to develop an API for todo and task management with Quarkus and Kafka?

Here are the general steps:

  1. Set up your development environment: Install the necessary software and tools, including Quarkus and Kafka. You can find instructions on how to do this in the Quarkus and Kafka documentation.

  2. Define your API: Determine what endpoints you need to expose in your API for managing tasks and todo items. This will depend on the specific requirements of your application. You can use a tool like OpenAPI to define your API.

  3. Implement the API endpoints: Write the code to handle the requests and responses for your API endpoints. You can use the Quarkus framework to implement the endpoints.

  4. Integrate Kafka: Use the Kafka Connect API to integrate Kafka into your application. This will allow you to publish and consume messages from your Kafka topics.

  5. Use Kafka for data synchronization: Use Kafka to keep your data in sync between different parts of your application. For example, you can use Kafka to send updates to a mobile app or web application when a user completes a task.

  6. Test your API: Write test cases for your API endpoints to ensure that they are working correctly.

  7. Deploy your application: Deploy your application to a production environment. You can use a tool like Docker or Kubernetes to manage your application's deployment.

These are the general steps to develop an API for todo and task management with Quarkus and Kafka. It's important to note that the specifics of your implementation may vary depending on your application's requirements.

1.1) Set up your development environment

Basic Quarkus app with DEV

brew install quarkusio/tap/quarkus
quarkus create app com.devilnside:todo:0.1 && cd todo
quarkus dev

open your browser to http://localhost:8080

Quickstart (the one used) with DEV

git clone https://github.com/quarkusio/quarkus-quickstarts.git
mv quarkus-quickstarts/kafka-panache-quickstart/* .
rm -rf quarkus-quickstarts
quarkus dev

open your browser to http://localhost:8080

Dockerfiles for DEV and PROD

Multiple dockerfiles are generated, we will use this image for now that uses the run-java.sh script to run the application. (Dockerfile.jvm):

FROM registry.access.redhat.com/ubi8/openjdk-17:1.14

ENV LANGUAGE='en_US:en'


# We make four distinct layers so if there are application changes the library layers can be re-used
COPY --chown=185 target/quarkus-app/lib/ /deployments/lib/
COPY --chown=185 target/quarkus-app/*.jar /deployments/
COPY --chown=185 target/quarkus-app/app/ /deployments/app/
COPY --chown=185 target/quarkus-app/quarkus/ /deployments/quarkus/

EXPOSE 8080
USER 185
ENV JAVA_OPTS="-Dquarkus.http.host=0.0.0.0 -Djava.util.logging.manager=org.jboss.logmanager.LogManager"
ENV JAVA_APP_JAR="/deployments/quarkus-run.jar"

Basic PROD scenario

Build the execution context image (with PGSQL & Kafka) and run it

# Before building the container image run:
./mvnw package

# Then, build the image with:
docker build -f src/main/docker/Dockerfile.jvm -t quarkus/todo-context-jvm .

# Then run the container using:
docker run -i --rm -p 8080:8080 quarkus/todo-context-jvm

Build the project and run it

mvn clean install -Pnative

or

quarkus build

then run it

./target/kafka-panache-quickstart-1.0.0-SNAPSHOT-runner

1.2) Define your API

1.3) Implement the API endpoints

1.4) Integrate Kafka

1.5) Use Kafka for data synchronization

1.6) Test your API

1.7) Deploy your application


Backlinks