Prerequisite:
-
Maven 3.x
-
JDK 11+
To build the project:
mvn clean install
The platform is available as a tar.gz and zip format in:
├── distribution
│ └── target
│ ├── esbcloud-distribution-1.0.0-SNAPSHOT.jar
│ ├── esbcloud-distribution-1.0.0-SNAPSHOT.tar.gz
│ ├── esbcloud-distribution-1.0.0-SNAPSHOT.zip
The main platform directory is:
├── distribution
│ └── target
│ ├── assembly
│ │ └── karaf
To run the platform in system out mode (for Docker):
./distribution/target/assembly/karaf/bin/karaf run
To run the platform in shell console:
./distribution/target/assembly/karaf/bin/karaf
To run the platform in background process:
./distribution/target/assembly/karaf/bin/start
The following properties can be set with system environment variables:
# Logging
LOG4J2_LOGGING_APPENDER_CONSOLE=Console
LOG4J2_LOGGING_PATTERN_CONSOLE={\"@timestamp\": \"%d{yyyy-MM-dd'T'HH:mm:ss.SSS}\", \"level\": \"%p\", \"logger\": \"%logger{63}:%L\", \"thread\": \"%t\", \"classname\": \"%class{63}\", \"message\": \"%encode{%m%wEx{full}}{JSON}\"}%n
# Kafka cluster notification
ESBCLOUD_KAFKA_BROKERS=localhost:9093
ESBCLOUD_KAFKA_TOPIC=dev.si.docawesome
ESBCLOUD_KAFKA_SECURITY_PROTOCOL=SASL_PLAINTEXT
ESBCLOUD_KAFKA_SECURITY_SASL_MECHANISM=SCRAM-SHA-512
ESBCLOUD_KAFKA_SECURITY_SASL_MODULE=org.apache.kafka.common.security.scram.ScramLoginModule
ESBCLOUD_KAFKA_SECURITY_SASL_USERNAME=esbcloud
ESBCLOUD_KAFKA_SECURITY_SASL_PASSWORD=changeit
# Expose api
ESBCLOUD_ENDPOINT_PROTOCOL=http
ESBCLOUD_ENDPOINT_HOST=localhost
ESBCLOUD_ENDPOINT_PORT=8080
ESBCLOUD_ENDPOINT_CXF_TRACE_ACTIVE=false
# API Gateway credentials for external poll
ESBCLOUD_POLL_CLIENT_USERNAME=esbcloud
ESBCLOUD_POLL_CLIENT_PASSWORD=changeit
When running the instance locally you can define the properties in
./distribution/target/assembly/karaf/bin/karaf/etc/io.yupiik.esb.routes.camelcontext.cfg
./distribution/target/assembly/karaf/bin/karaf/etc/io.yupiik.esb.services.endpoint.camelcontext.cfg
./distribution/target/assembly/karaf/bin/karaf/etc/io.yupiik.esb.services.observability.camelcontext.cfg
Properties are loaded by Felix ConfigAdmin interpolate:
# API published entrypoint
esbcloud.endpoint.host=$[env:ESBCLOUD_ENDPOINT_HOST=localhost]
esbcloud.endpoint.port=$[env:ESBCLOUD_ENDPOINT_PORT=8080]
esbcloud.endpoint.protocol=$[env:ESBCLOUD_ENDPOINT_PROTOCOL=http]
esbcloud.endpoint.cxf.trace.active==$[env:ESBCLOUD_ENDPOINT_CXF_TRACE_ACTIVE;default=false]
You can replace the default values.
To debug code you have to run the distribution in debug mode:
./distribution/target/assembly/karaf/bin/karaf debug
Remote debug is now available on localhost:5005
Then you can activate the bundle refresh watching:
karaf@root()> bundle:watch *
When building a maven module, it will be automatically reloaded in the running instance. You don’t need to build all the project.
Tail log:
karaf@root()> log:tail
curl -X 'POST' \
'http://localhost:8080/notification' \
-H 'accept: application/json;charset=utf-8' \
-H 'X-Routing-System: jms' \
-H 'Content-Type: application/json;charset=utf-8' \
-d '{
"reference": "INF161200001",
"date": "01/01/1970 00:00:00",
"message": "Update contract"
}'
curl -X 'POST' \
'http://localhost:8080/notification' \
-H 'accept: application/json;charset=utf-8' \
-H 'X-Routing-System: kafka' \
-H 'Content-Type: application/json;charset=utf-8' \
-d '{
"reference": "INF161200001",
"date": "01/01/1970 00:00:00",
"message": "Update contract"
}'
curl -X 'POST' \
'https://localhost:8080/notification' \
-H 'accept: application/json;charset=utf-8' \
-H 'X-Routing-System: unknown' \
-H 'Content-Type: application/json;charset=utf-8' \
-d '{
"reference": "INF161200001",
"date": "01/01/1970 00:00:00",
"message": "Update contract"
}'
The cucumber e2e tests are located in the esbcloud-distribution
module.
To launch them, just run the command:
mvn test -Pe2e-on-dev
The configuration of the docker build is done with the maven-jib-plugin
<plugin>
<groupId>com.google.cloud.tools</groupId>
<artifactId>jib-maven-plugin</artifactId>
<version>3.3.1</version>
<configuration>
<allowInsecureRegistries>true</allowInsecureRegistries>
<from>
<image>ossyupiik/java:17.0.4</image> (1)
</from>
<to>
<image>io.yupiik.esbcloud/esbcloud-distribution:${project.version}</image> (2)
</to>
<container>
<entrypoint> (3)
<entrypoint>/karaf/bin/karaf</entrypoint>
<entrypoint>run</entrypoint>
</entrypoint>
<workingDirectory>/karaf</workingDirectory>
</container>
<extraDirectories>
<paths>
<path>target/assembly</path>
</paths>
<permissions>
<permission>
<file>/karaf/bin/karaf</file>
<mode>755</mode>
</permission>
</permissions>
</extraDirectories>
</configuration>
</plugin>
-
The docker image base
-
The docker image to build
-
The entrypoint of the command to execute when running the docker
Health checks are available at:
-
http://host:8080/health/liveness
for the liveness probe -
http://host:8080/health/readiness
for the readiness probe
mvn compile jib:dockerBuild
You can see the image on your local docker registry:
docker images
>
REPOSITORY TAG IMAGE ID CREATED SIZE
io.yupiik.esbcloud/esbcloud-distribution 1.0.0-SNAPSHOT 29df4227923c 1 years ago 490MB
Now you can run a container:
docker run -it --name esbcloud io.yupiik.esbcloud/esbcloud-distribution:1.0.0-SNAPSHOT