Git Product home page Git Product logo

spring-boot-cloud-camel-composite-service-saga-inmemory's Introduction

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.

spring-boot-cloud-camel-composite-service-saga-inmemory's People

Contributors

hamedmirzaei avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.