This is a simple example to show you how to implement a Saga EIP over simple
services using Apache Camel and Spring Cloud
- [Module]
Spring Boot - [Module]
Spring Cloud - [Integration Framework]
Apache Camel - [ORM]
Hibernateunder abstraction ofSpring Data JPA - [Database]
MySQL on port 3306 - [Tool]
Locust: Tool for load test - [Library]
DataFactory: Library for generating fake data
We provided three different demos over here.
- Account/Transaction financial business situation demo (Im-memory Saga EIP)
- Transaction between two different banks demo (Im-memory Saga EIP)
- Load balancing demo (Zuul)
This is a common and simple banking business flow. There is a simple Customer and Account service. Each customer is
connected to some accounts. Besides for each account, there is some number of transactions over it which is provided and
handled by Transaction service.
There is also a Camel service which tries to implement Saga EIP over Account and Transaction services.
All these services are registered in Eureka as the service registry and discovery framework.
- Start
eureka-servermodule. It can be verified using url http://localhost:8761/. - Start
account-servicemodule. It can be verified using url http://localhost:8762/api/accounts/health. - Start
transaction-servicemodule. It can be verified using url http://localhost:8763/api/transactions/health. - Start
camel-servicemodule. It can be verified using url http://localhost:8764/health.
Now your services are up and you can send transactions as JSON type with Http.POST method to
http://localhost:8764/make-transaction url.
Or, you can simply do the load test explained bellow.
You should have Python and Locust installed on your system to do the load test part. To do the load test
simply run the following through the terminal in project root path:
cd \path\to\project\spring-boot-cloud-camel-composite-service
\path\to\locust\locust.exe -f load-test\locustfile.py
This starts the locust on http://localhost:8089
You can set number of users and catch size and then start the test
It sends a lot of Http.POST requests to http://localhost:8764/make-transactions
This is another common and simple banking business flow. There is a simple Bank-A and Bank-B service. Each bank
has a repository of transactions. We are trying to exemplify a simple transaction between banks model using Saga EIP.
There is another Camel service which tries to implement Saga EIP over Bank-A and Bank-B services.
All these services are registered in Eureka as the service registry and discovery framework.
- Start
eureka-servermodule. It can be verified using url http://localhost:8761/. - Start
bank-a-servicemodule. It can be verified using url http://localhost:8765/transactions. - Start
bank-b-servicemodule. It can be verified using url http://localhost:8766/transactions. - Start
camel-transfer-servicemodule. It can be verified using url http://localhost:8767/health.
Now your services are up and you can send transactions as JSON type with Http.POST method to
http://localhost:8767/transfer url.
Or, you can simply do the load test explained bellow.
You should have Python and Locust installed on your system to do the load test part. To do the load test
simply run the following through the terminal in project root path:
cd \path\to\project\spring-boot-cloud-camel-composite-service
\path\to\locust\locust.exe -f load-test\locustfile-transfer.py
This starts the locust on http://localhost:8089
You can set number of users and catch size and then start the test
It sends a lot of Http.POST requests to http://localhost:8767/transfer
Zuul, among many other things, fetches from Eureka service locations and does server-side load balancing.
In order to test it, we add another instance for account-service named account-service-instance2.
This service has the same name as the account-service when he wants to register itself on Eureka.

- Before all you need to setup a
MySQLdatabase and create a schemacamel_schema. It sould listen on default port3306with username/password asroot/root. Or you may want to change all theapplication.propertiesfiles to your connection url. - Start
eureka-servermodule. It can be verified using url http://localhost:8761/. - Start
account-servicemodule. It can be verified using url http://localhost:8762/api/accounts/health. - Start
transaction-servicemodule. It can be verified using url http://localhost:8763/api/transactions/health. - Start
camel-servicemodule. It can be verified using url http://localhost:8764/health. - [Optional] Start
account-service-instance2module. It can be verified using url http://localhost:8769/api/accounts/health. - [Optional] Start
transaction-service-instance2module. It can be verified using url http://localhost:8771/api/transactions/health. - [Optional] Start
camel-service-instance2module. It can be verified using url http://localhost:8769/health. - Start
zuul-servermodule. It can be verified using url http://localhost:8768/actuator/info.
When Zuul receives a request, it picks up one of the physical locations available and forwards requests to the actual service instance. The whole process of caching the location of the service instances and forwarding the request to the actual location is provided out of the box with no additional configurations needed.
Internally, Zuul uses Netflix Ribbon to look up for all instances of the service from the service discovery (Eureka Server).
Now you can receive accounts information through http://localhost:8768/account-service/api/accounts.
The request received by Zuul is forwarded to different instances of account-service in a round robin fashion.

