Giter VIP home page Giter VIP logo

cf-springboottrader's Introduction

This repository is no longer maintained. The project has moved here

cf-SpringBootTrader

Microservice version of the Spring Trader app using spring boot

Spring Trader

#Introduction

This repository holds a collection of micro services that work together to present a trading application surfaced though a web UI, but more interfaces can be created that re-utilise the microservices.

It was created to support workshops and demonstrations of building and using microservices architectures and running these in Cloud Foundry (although it is possible to run these on other runtimes).

The workshops follow a series of exercises, or labs, and you can find links to the guides for these exercises below.

##Table of Contents

  1. Architecture
  2. Deploying the application
  3. Workshops
  4. Demos
  5. Roadmap
  6. Contributing to the project

#Architecture The system is composed of 4 microservices. The relationship between the microservices is illustrated below.

architecture

##1. Quote Microservice This service is a spring boot application responsible for providing up to date company and ticker/quote information. It does this by providing a REST api with 2 calls:

  • /quotes?q={symbols} Returns an up to date quote for each symbol in the comma-delimited list.
  • /company/{search} Returns a list of companies that have the search parameter in their names or symbols.

This application has no dependencies apart from an external service - markitondemand - to retrieve the real time data.

##2. Account Microservice This service is a spring boot application responsible for creating and managing user accounts.

It stores the accounts in a RDBMS store and uses a spring JPA respository to accomplish this. It provides several REST api calls for other services to consume its services.

##3. Portfolio Microservice This service is a spring boot application responsible for managing portfolios - these are collections of holdings, which in turn are collection of orders on a particular share.

This service accepts orders (both BUY and SELL) and stores these in a RDBMS store - it does not have to be the same RDBMS as the Account service, but it can be! It provides REST api calls for other services to consume its services.

This service is dependent on the Account service above to ensure the logged in user has enough funds to buy stock as well as keeping the account funds up to date. It is also dependent on the Quote service to retrieve up to date quote information and calculate the current value of portfolios.

##4. Web Microservice This service is a spring boot application providing the web interface.

The web interface is built using bootstrap and Thymeleaf and uses a Spring controller to delegate calls to the relevant services:

  • Account service
  • Quote service
  • Portfolio service

#Deployment

To deploy the microservices please follow the guides of the workshop below.

Each guide includes instructions on how to deploy and run to:

#Workshops:

The following guides describe how to setup the environment and deploy the microservices to Cloud Foundry.

At Pivotal we love education, not just educating ourselves, but also educating others. As such, these guides follow the "teaching you how to fish" principle - Rather than giving you line by line/command by command instructions, we provide guidelines and links to documentation where you can read and learn more.

  1. [Setting up the environment] setup
  2. [Creating a discovery service] registry
  3. [Creating a circuit breaker dashboard] circuitbreaker
  4. creating the configuration service
  5. [Pushing the Quote service] pushquote
  6. [Pushing all the services] pushall
  7. [Scaling the services] scale
  8. Auto Scaling - TODO: use autoscaler service!
  9. [Blue/Green deployments] bluegreen
  10. Monitor workshop - TODO: show how to monitor microservices using springbootadmin, ELK tile and Zipkin.

#Demos

###1. Deploying to Pivotal Cloud Foundry. TODO: document a walk through of this demo. This is a walkthough of the workshop above.

  • Deploying microservices to Cloud Foundry.
  • Creating and binding services to applications.

###2. Service discovery. TODO: document a walk through of this demo.

###3. Scalability TODO: document a walk through of this demo.

  • provide a load generator to mimic users.
  • scale instances.

###4. Configuration Management. TODO: document a walk through of this demo.

###5. Traceability across all services. TODO: document a walk through of this demo using Zipkin and Kibana.

###6. Continuous Integration/Continuous Delivery. TODO: document a walk through of this demo.

###7. Operations Demo TODO: document how to operate/monitor several microservices, using Spring Boot Admin and ELK tile

#Features

  • Discovery service: All microservices register with the Discovery Service and discover other microservices through it.
  • Correlation/Traceability: Traceability of requests through all the microservices. This is done using Spring-cloud-sleuth.
  • Config Server: The microservices obtain the configuration from a Configuration Service backed by a git repository. This means that configuration is now auditables and version controlled, as well as providing the ability to refresh configuration during runtime.

#Roadmap

The roadmap for this project is constantly evolving. Please feel free to reach out with ideas.

  • Better APIs: Better APIs with documentation that conform to some standard and logic.
  • Security: Secure microservices with OAUTH2.
  • Monitoring/Operations: Show how to monitor a distributed system comprising of multiple microservices. This will comprise of:
    • Spring Boot Admin
    • ELK tile
    • Zipkin
  • Stock analysis system: A microservice, or set of microservices, to analyse stock and provide recommendations. Also, to show polyglot persistence as well as more sophisticated data workloads.
  • Mobile UI: Mobile interface to expose the services on an iOS device and/or Android device natively, making use of the Pivotal Cloud Foundry Mobile Services.

#Contributing Everyone is encouraged to help improved this project.

The master branch has the latest stable release. development happens in the development branch (or feature branches that get merged into development branch). So please check if want you to develop is already in the development branch.

Here are some ways you can contribute:

  • by using alpha, beta, and prerelease versions (ie from the development branch)
  • by reporting bugs
  • by suggesting new features
  • by writing or editing documentation
  • by writing code (no patch is too small: fix typos, add comments, clean up inconsistent whitespace)
  • by refactoring code
  • by closing issues

##Submitting an Issue

We use the GitHub issue tracker to track bugs and features. Before submitting a bug report or feature request, check to make sure it hasn't already been submitted. When submitting a bug report, please include any relevant information. Ideally, a bug report should include a pull request with failing specs, and maybe even a fix!

##Submitting a Pull Request

  1. Fork the project.
  2. Create a topic branch.
  3. Implement your feature or bug fix.
  4. Commit and push your changes.
  5. Submit a pull request (to the development branch).

cf-springboottrader's People

Contributors

davpin avatar fifthposition avatar mikegehard avatar svrc avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

cf-springboottrader's Issues

API versioning

improve controllers so we can have better API management (i.e. versioning). For example, have "/v1/" in the path so we can have multiple concurrent versions.

Also, try to improve APIs (format, syntax, structure, docs).

issue with data coming back from quote service

at specific times of day, the UI displays nothing and curling the UI gives the following error:
{"timestamp":1452867880919,"status":500,"error":"Internal Server Error","exception":"org.thymeleaf.exceptions.TemplateProcessingException","message":"Error formatting decimal with minimum integer digits = 0, thousands point type = COMMA, decimal digits = 2 and decimal point type = POINT (fragments/marketsummary_fragment:67)","path":"/"}

Seems to suggest there is something wrong with the data passed to the UI.

NamedContextFactory Not Found Error when running discovery service locally

2018-03-08 02:53:46.904 ERROR 8608 --- [trace=,span=] [ main] o.s.boot.SpringApplication : Application startup failedjava.lang.IllegalStateException: Could not evaluate condition on org.springframework.cloud.netflix.ribbon.eureka.RibbonEurekaAutoConfiguration due to org/springframework/cloud/context/named/NamedContextFactory not found. Make sure your own configuration does not rely on that class. This can also happen if you are @ComponentScanning a springframework package (e.g. if you puΓÇ¿ at org.springframework.boot.autoconfigure.condition.SpringBootCondition.matches(SpringBootCondition.java:55) ~[spring-boot-autoconfigure-1.4.5.RELEASE.jar:1.4.5.RELΓÇ¿ at org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader$TrackedConditionEvaluator.shouldSkip(ConfigurationClassBeanDefinitionReader.java:43ΓÇ¿ at org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.loadBeanDefinitionsForConfigurationClass(ConfigurationClassBeanDefinitionReader.javΓÇ¿ at org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.loadBeanDefinitions(ConfigurationClassBeanDefinitionReader.java:116) ~[spring-conteΓÇ¿ at org.springframework.context.annotation.ConfigurationClassPostProcessor.processConfigBeanDefinitions(ConfigurationClassPostProcessor.java:320) ~[spring-context-4.ΓÇ¿ at org.springframework.context.annotation.ConfigurationClassPostProcessor.postProcessBeanDefinitionRegistry(ConfigurationClassPostProcessor.java:228) ~[spring-conteΓÇ¿ at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanDefinitio nΓÇ¿ at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:93) ~[spring-contextΓÇ¿ at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:686) ~[spring-context-4.3.7.RELEASΓÇ¿ at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:122) ~[spring-boot-1.4.5.RELEASE.jar:1.4.5.RELΓÇ¿ at java.net.URLClassLoader.defineClass(URLClassLoader.java:467) ~[na:1.8.0_162]:1.8.0_162]Factory.RELEASE.jar:1.4.5.RELEASE]5.RELEASE] tΓÇ¿ at org.springframework.core.type.classreading.AnnotationReadingVisitorUtils.convertClassValues(AnnotationReadingVisitorUtils.java:78) ~[spring-core-4.3.7.RELEASE.jaΓÇ¿ at org.springframework.core.type.classreading.AnnotationMetadataReadingVisitor.getAnnotationAttributes(AnnotationMetadataReadingVisitor.java:134) ~[spring-core-4.3.ΓÇ¿ at org.springframework.core.type.classreading.AnnotationMetadataReadingVisitor.getAnnotationAttributes(AnnotationMetadataReadingVisitor.java:127) ~[spring-core-4.3.ΓÇ¿ at org.springframework.core.type.classreading.AnnotationMetadataReadingVisitor.getAnnotationAttributes(AnnotationMetadataReadingVisitor.java:49) ~[spring-core-4.3.7ΓÇ¿ at org.springframework.boot.autoconfigure.condition.OnBeanCondition$BeanSearchSpec.(OnBeanCondition.java:290) ~[spring-boot-autoconfigure-1.4.5.RELEASE.jar:1.ΓÇ¿ at org.springframework.boot.autoconfigure.condition.OnBeanCondition.getMatchOutcome(OnBeanCondition.java:79) ~[spring-boot-autoconfigure-1.4.5.RELEASE.jar:1.4.5.RELΓÇ¿ at org.springframework.boot.autoconfigure.condition.AbstractNestedCondition$MemberOutcomes.getConditionOutcome(AbstractNestedCondition.java:194) ~[spring-boot-autocΓÇ¿ at org.springframework.boot.autoconfigure.condition.AbstractNestedCondition$M eΓÇ¿ at org.springframework.boot.autoconfigure.condition.AbstractNestedCondition$MemberConditions.getMatchOutcomes(AbstractNestedCondition.java:165) ~[spring-boot-autocoΓÇ¿ at org.springframework.boot.autoconfigure.condition.AbstractNestedCondition$MemberMatchOutcomes.(AbstractNestedCondition.java:80) ~[spring-boot-autoconfigure-ΓÇ¿ at org.springframework.boot.autoconfigure.condition.AbstractNestedCondition.getMatchOutcome(AbstractNestedCondition.java:64) ~[spring-boot-autoconfigure-1.4.5.RELEAΓÇ¿ at org.springframework.boot.autoconfigure.condition.AllNestedConditions.getMatchOutcome(AllNestedConditions.java:45) ~[spring-boot-autoconfigure-1.4.5.RELEASE.jar:1ΓÇ¿ at org.springframework.boot.autoconfigure.condition.SpringBootCondition.matches(SpringBootCondition.java:47) ~[spring-boot-autoconfigure-1.4.5.RELEASE.jar:1.4.5.RELΓÇ¿ ... 42 common frames omitteddClass(ClassLoader.java:357) ~[na:1.8.0_162]8.0_162]NamedContextFactory
2018-03-08 02:53:46.904 INFO 8608 --- [trace=,span=] [ main] ationConfigEmbeddedWebApplicationContext : Closing org.springframework.boot.contex

Continuous Delivery Support for Spring Trader

As a working demo of microservices in action, Spring Trader lends itself very well to showing continuous delivery and zero-downtime deployments. Individual services can easily be tested and updated while the application as a whole continues to operate.

Jenkins is the most popular field tool for CI/CD demos, but the project as currently organized doesn't work well with Jenkins. Jenkins can generate generic "something in this Github repo has changed" events, and trigger a build off of that. But the Github plugin for Jenkins will not work at the granularity of identifying which files have changed, in order to determine which services need to be deployed.

So for field demos, we have had to clone the project, and set up a "one-repo-per-microservice" structure in order to create a Jenkins demo that can build and deploy the correct service on code change.

Does it make sense to reorganize this project in that way, or is there a suggested alternative method for doing CI/CD demos?

Mobile UI

create a Mobile UI to show off the mobile services of PCF

Upgrade UI

Upgrade web UI to a more version of bootstrap. Currently using bootstrap 2.3.2.

add secondary external quote service

The quote service is using markitondemand to retrieve quote and company information. This is being used because it is free with no limits on number of calls. However, it is very temperamental.

A secondary service should be added, yahoo finance for example, with hystrix to handle the failed calls to markitondemand.

create market summary service

Currently the summary of quotes on page header is 3 FS and 3 IT quotes picked at random from a list. And the market summary is hard coded to zeros.

There should be a service to retrieve this information from somewhere and instead of being 3 FS and 3 IT quotes, should be 3 top performers and 3 worst performers.

Testing

Currently we have ok unit test coverage for quotes, accounts and portfolio (although probably should have more and better ones).

Issues are:

  • some unit tests are not really unit tests as they call out to external services. these should be contained to code.
  • no integration testing

Building a CI pipeline using concourse, so probably a good idea to have more automated testing as this will allow to release more often.

sbt_pipeline

It would be good if we could have integration testing for each service and also some end-2-end testing (maybe with selenium???)

create Demos

Create the demos and documentation for the demos listed in the docs.

Build fails in different locales from english

The build fails due to not being able to parse dates from json:

`
java.text.ParseException: Unparseable date: "Wed May 6 00:00:00 UTC-04:00 2015"

at java.text.DateFormat.parse(DateFormat.java:366)

at io.pivotal.quotes.configuration.TestConfiguration.quote(TestConfiguration.java:43)

`

and
`
com.fasterxml.jackson.databind.JsonMappingException: Failed to parse Date value 'Thu Jun 11 00:00:00 UTC-04:00 2015' (format: "EEE MMM dd HH:mm:ss zzzXXX yyyy"): Unparseable date: "Thu Jun 11 00:00:00 UTC-04:00 2015" (through reference chain: io.pivotal.quotes.domain.Quote["Timestamp"])

        at com.fasterxml.jackson.databind.JsonMappingException.wrapWithPath(JsonMappingException.java:210)

        at com.fasterxml.jackson.databind.JsonMappingException.wrapWithPath(JsonMappingException.java:177)

`

Thanks to @flambiente-pivotal for uncovering this.

Logging

Fix and enhance the logging within the micro services to a more logical, standard way.

Config Server

Add config server to the architecture so all services get their config from the config server.

services running out of Metaspace

Services are crashing due to running out of meatspace.
2015-10-18T10:28:45.12+0100 [App/0] OUT # 2015-10-18T10:28:45.12+0100 [App/0] OUT # java.lang.OutOfMemoryError: Metaspace

breakdown account service

Split account service into a user account and a DDA - Demand Debit Account Service. The user account is responsible for the user information (id, name, address, password, etc). The DDA is responsible for keeping track of the transactions on the account (i.e. debits and credits) and overall balance.

Also, the password should be split out from the "account" object and stored safely, i.e. a salted.

Some micro services don't run locally.

Some micro services cannot run locally, any that depend on user-provided services. The services use spring cloud connectors to know about each other and only the cloud foundry connectors have been implemented.

XIgnite quote service has expired

account and token for use of XIgnote service has expired.

We shouldn't really be using services that we need to register for, or that there are expiration dates or low threshold limits of use.

Need to add to the docs on how to create account and change token for now, but look at using different service - specially now that we have yahoo quotes as well.

Add caching service to quotes service

Add a caching service to the quotes service so that we don't have to go to the external service every time. Use expiry to remove stale data from the cache.

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.