Skip to content
This repository has been archived by the owner on Aug 6, 2022. It is now read-only.

Latest commit

 

History

History
123 lines (81 loc) · 3.28 KB

README.md

File metadata and controls

123 lines (81 loc) · 3.28 KB

XPENSES

Why ?

This application allows several users to track and share their expenses.

Please notice the first version can manage up to 2 users, as the next versions will be available to more users.

Some configuration files are deliberately missing.

Creating a native executable

You can create a native executable using:

mvnci -Pnative

Or, if you don't have GraalVM installed, you can run the native executable build in a container using:

Note : quarkus.native.native-image-xmx args must be set for macos and Windows in order to allocate enough memory when building the image.

mvnci -Pnative -Dquarkus.native.container-build=true -Dquarkus.native.native-image-xmx=4g

Running the image

docker run -i --rm -p 8080:8080 quarkus/xpenses-quarkus  

Native executable code

https://quarkus.io/guides/writing-native-applications-tips

The following dependency must be added for serialization

<dependency>
    <groupId>io.quarkus</groupId>
    <artifactId>quarkus-resteasy-jsonb</artifactId>
</dependency>
  • Entities must be annotated by @RegisterForReflection to be included in the native executable.
  • Entities must contain at least a default constructor and a constructor with all parameters.
  • Entities constructors cannot be generated from Lombok annotations.

Kubernetes Kafka setup

https://strimzi.io/quickstarts

YAML :

Run everything

# Increase memory to support kafka cluster
minikube start --memory=4096 

# Create namespace
kubectl create ns kafka

# Enable storage to minikube for built images
eval $(minikube -p minikube docker-env)

cd service
mvn package
docker build -f src/main/docker/Dockerfile.jvm . -t xpenses-quarkus

# Set up Kafka cluster https://strimzi.io/quickstarts
kubectl create -f 'https://strimzi.io/install/latest?namespace=kafka' -n kafka
kubectl apply -f https://strimzi.io/examples/latest/kafka/kafka-persistent-single.yaml -n kafka
kubectl wait kafka/my-cluster --for=condition=Ready --timeout=300s -n kafka

# Set up environment
kubectl create -f src/main/kubernetes/all-in-one.yaml

# Get minikube tunnel info to use the service
minikube service -n kafka xpenses-quarkus-service

# Use the localhost ip to connect to the application

Kamel Kafka

Create a Kamel application to listen from the given kafka topic and performs actions following the Enterprise Integration Patterns.

Install the Kamel CLI to deploy the application in K8s

MacOs

# Install the CLI
brew install kamel

# Add the CLI to the cluster and given namespace
kamel install -n kafka

# Deploy the application to the namespace
kamel run kamel/src/main/java/org/thoms/ExpensesKamel.java -n kafka --dev

### OPTIONAL
# Reset if any errors occurred
kamel reset -n kafka

# You may need to run this after reset
kamel run kamel/src/main/java/org/thoms/ExpensesKamel.java -n kafka

Useful links