Skip to content

Spring Boot + Spring Cloud + Apache Camel simple application to create composite service + saga service

Notifications You must be signed in to change notification settings

hamedmirzaei/spring-boot-cloud-camel-composite-service-saga-inmemory

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

29 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Spring Boot + Spring Data + Apache Camel (Service Composition Using Saga EIP Example)

This is a simple example to show you how to implement a Saga EIP over simple services using Apache Camel and Spring Cloud

Libraries and Tools

How it works

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)

Account/Transaction financial business situation demo (Im-memory Saga EIP)

Architecture

Architecture

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.

How to run

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.

Load test

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

Transaction between two different banks demo (Im-memory Saga EIP)

Architecture

Architecture

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.

How to run

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.

Load Test

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

Load balancing demo (Zuul)

Architecture

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. Architecture

How to run

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.

About

Spring Boot + Spring Cloud + Apache Camel simple application to create composite service + saga service

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published