Coder Social home page Coder Social logo

trade-processor's Introduction

Market Trade Processor

This project is a prototype, coded with no much time available, capable of handling a large number of trade messages per second by receiving them through a HTTP endpoint, which takes JSON as payload. By prototype I mean something functional in processing lots of trade, but generally some things act naively.

Overview

This project was built using microservices approach on top of Java, which leverages some well known open-source technologies like Spring, Hibernate, Eureka, Zuul, Feign, OAuth2, Maven, JUnit, Mockito, Gatling, Lombok, Mysql, Docker compose.

Some of the main characteristics of a microservices-based application are functional decomposition, well-defined interfaces and single resposibility. In other words, microservice allows us to get loose coupling, high cohesion, agility, flexibility and scalability.

Here're some patterns related to microservice:

Microservice Patterns

With this in mind the trade processor was split into the following Maven modules:

Inside each module you can find a brief doc around them.

Requirements

  • Java 8
  • Maven 3
  • Docker compose 1.8

How to run

  1. Fork the project
  2. Build: mvn install
  3. Before running docker make sure all exposed ports in the docker compose file are really available
  4. Run docker-compose to start up all services together: docker-compose up
  5. Allow some seconds until all services are running and properly registered within Service Discovery

Security

Now you've got everything up and running you must authenticate in order to be able to call the main entrypoint. With the following info you must be able to get the OAuth2 token:

Using Postman to get access token:

Postman token

Load testing

Optionally you can get the load-testing Maven project to inject random trade data using the following command:

mvn gatling:test -Doauth2.token=YOUR-GENERATED-OAUTH-TOKEN

Remember to do the security step to get a valid oauth token.

Useful endpoints

http://docker-host:8080/consumption/trade (main entry point)

{
  "userId" : 134256,
  "currencyFrom" : "EUR",
  "currencyTo" : "GBP",
  "amountSell" : 1000.0,
  "amountBuy" : 747.1,
  "rate" : 0.7471,
  "timePlaced" : "24-JAN-15 10:27:44",
  "originatingCountry" : "FR"
}

http://docker-host:8080/consumption/trades (batch consume)

http://docker-host:8080/processing/trade (simple http entry point that exposes stored trade messages)

ws://docker-host:8080/processing/real-time (websocket entry point that exposes the latest metrics)

ws://docker-host:8080/processing/real-time/history (websocket entry point that exposes metric history)

Note that all entry points are taking into account the API Gateway port.

References

  1. http://microservices.io/patterns/microservices.html
  2. https://www.infoq.com/articles/microservices-intro
  3. http://martinfowler.com/articles/microservices.html
  4. https://spring.io/blog/2015/07/14/microservices-with-spring

trade-processor's People

Contributors

carlosraphael avatar

Stargazers

Thiago Leite avatar

Watchers

James Cloos avatar Thiago Leite 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.