Git Product home page Git Product logo

forex-service's Introduction

Overview

  • This is an application to showcase how to integrate a spring-boot project with a 3rd party FOREX or Foreign Exchange service.
  • On this example, we'll try to mimic the behavior of having a service that's scheduled to pull rates from an external Forex service and persist them within our on-premise Oracle database.
  • We'll utilize Oracle's coherence cache to increase our performance, hence we need to maintain the integrity of our records at the same time, so we don't end up utilizing invalid trade rates.
  • Whenever trade rates are refreshed, a batching update for all trade rates will be executed.
  • The project consists of two modules; one is forex-service , and the second one is cache-server.

Acknowledgements

Thanks to exchangerate.host for providing their free FOREX API.

exchangerate.host is a Free foreign exchange, crypto rates & EU VAT Rates API.
If you or your company use this project or like what they're doing, please consider backing them, so they can continue maintaining and evolving this wonderful project.

exchangerate.host

Testing

  1. Run the oracle service from this docker-compose file.
  2. Login using:
usernamesystem
passwordPass@12345
urljdbc:oracle:thin:@localhost:1521:XE
  1. Create a new user named forex with password Forex@12345.
  2. Verify user existence:
SELECT * FROM all_users;
  1. Grant the following permissions to forex.
GRANT CONNECT, RESOURCE, DBA TO FOREX;
  1. The first time you run the application, ExchangeRateClient will load all rates automatically.
  2. You can look up scheduled tasks on JobRunr dashboard.
  3. Load this .collections file into your postman and enjoy.

Guides

Cache Concurrency Strategy on Hibernate

  • READ_ONLY: Used only for entities that never change (exception is thrown if an attempt to update such an entity is made). It's very simple and performative. It's suitable for static reference data that doesn't change.
  • NONSTRICT_READ_WRITE: Cache is updated after the transaction that changed the affected data has been committed. Thus, strong consistency isn't guaranteed, and there's a small-time window in which stale data may be obtained from the cache. This kind of strategy is suitable for use cases that can tolerate eventual consistency.
  • READ_WRITE: This strategy guarantees strong consistency, which it achieves by using ‘soft' locks. When a cached entity is updated, a soft lock is stored in the cache for that entity as well, which is released after the transaction is committed. All concurrent transactions that access soft-locked entries will fetch the corresponding data directly from the database.
  • TRANSACTIONAL: Cache changes are done in distributed XA transactions. A change in a cached entity is either committed or rolled back in both the database and cache in the same XA transaction.

JobRunr is a Java library that makes it easy to run background jobs in a Java application. It provides a simple and consistent API for scheduling, executing, and managing jobs in a variety of environments, including web applications and microservices.
More info: spring-integration & recurring jobs.

Helpful cron expressions:

Every minute: 0 */1 * * * *.
Every 5 minutes: 0 */5 * * * *.
Every day at 04:00 pm: 0 0 16 * * *.
Every day at 12:05 am: 0 5 0 * * *.


Linkedin

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.