This project contains a few examples how to use Apache Camel to resolve fictious use cases. The examples can be run using Maven. When using the Maven command, Maven will attempt to download the required dependencies from a central repository to your local repository.
The sample node applications are required to run TCP Socket routes.
-
Clone the project:
$ git clone https://github.com/sdriton/camel-microservice.git
-
Install the dependencies:
$ mvn install
-
Add this environment variable in your terminal shell
export CAMEL_KEYSTORE_PASSWORD=Camel123!
-
Copy sample CSV file to /tmp directory (or the preferred directory)
$ cp ./src/main/resources/static/employees-basic.csv /tmp
-
Execute:
$ mvn clean compile exec:java
- Package
$ mvn clean compile package
- Run
Using default parameters:
$ java -Xms1g -Xmx2g -XX:MaxMetaspaceSize=2g -XX:+UseG1GC -XX:MaxGCPauseMillis=500 -jar ./target/camel-microservice-0.0.1.jar
Using custom parameters:
$ java -Xms1g -Xmx2g -XX:MaxMetaspaceSize=2g -XX:+UseG1GC -XX:MaxGCPauseMillis=500 -Dserver.port=8090 -Dspring.profiles.active=dev -jar ./target/camel-microservice-0.0.1.jar
Parameters:
1. server.port=8091 - The port of the HTTP server
2. spring.profiles.active=dev - The active profile for which the yaml file will be used. In this case application-dev.yaml will be used.
To create a self signed cerificate and import it into the keystore follow these steps:
Using KeyChain Access create certificate and export it as PKCS12 - Here are the steps.
Other tools such as OpenSSL or Java keytool can be used to create the certificate.
-
Import the certificate:
keytool -importkeystore -srckeystore apache-camel-poc.p12 -srcstoretype PKCS12 -destkeystore camel-keystore.jks -deststoretype JKS -srcstorepass <password> -deststorepass <password> -destkeypass <password> -noprompt
-
List the contents of the truststore to check if the certificate has been imported:
keytool -list -v -keystore camel-keystore.jks
-
Configure in SSLContextParamsConfiguration class the SSL Context.
-
Optional. Import the certificate to the cacerts
keytool -importcert -file jetty.crt -alias jetty -keystore $JAVA_HOME/jre/lib/security/cacerts
$ docker-compose up
Build the docker image
$ docker build -f .docker/Dockerfile -t driton/camel-microservice . --build-arg SERVER_PORT=8090
Create a bridge network
$ docker network create -d bridge camel_microservice_internal_network
Run the container on port 8090
$ docker run --env CAMEL_KEYSTORE_PASSWORD=Camel123! \
-p 127.0.0.1:8090:8090/tcp \
--name driton-camel-microservice \
-v tempVolume:/tmp \
--network=camel_microservice_internal_network \
--rm -it driton/camel-microservice:latest
For further reference, please consider the following sections:
- Official Apache Maven documentation
- Spring Boot Maven Plugin Reference Guide
- Create an OCI image
- Spring Boot Actuator
- Spring Boot DevTools
- Spring Web
The following guides illustrate how to use some features concretely: