Giter VIP home page Giter VIP logo

qbit-event-bus-cluster-sample's Introduction

QBit's Event Bus Cluster Sample

This is a sample implementation of a clustered event bus using QBit library.

Usage

Start the components:

  • Consul server agent
    • it should listen on the standard endpoint localhost:8500
  • 1st instance of the service
    • TransactionClassifierServiceInstance1
  • 2nd instance of the service
    • TransactionClassifierServiceInstance2

Note: Send the request to one of the instances and you will see that:

  • the http request is processed by that instance
  • the event (generated based on the request) is consumed by both instances
    (through the help of the clustered event bus).

Example 1: As a GET request to the first instance:

  • sending the request:
$ curl -sS http://localhost:8881/classify/txn/123/456/17/EUR  -H "Content-Type: application/json"
"success"
$
  • 1st instance output will show:
[classifyAsGet] fromAccount='123' toAccount='456' amount=17.000000 currency='EUR'

[onClassifyTransactionEvent] Transaction{ fromAccount='123', toAccount='456', amount=17.000000, currency='EUR' }
  • 2nd instance output will show:
[onClassifyTransactionEvent] Transaction{ fromAccount='123', toAccount='456', amount=17.000000, currency='EUR' }

Example 2: As a POST request to the second instance:

  • sending the request:
$ curl -sS -X POST  http://localhost:8881/classify/txn \
       -H "Content-Type: application/json" \
       -d '{ "fromAccount":"123", "toAccount":"456", "amount":17, "currency":"EUR" }'
"success"
$
  • 1st instance output will show:
[classifyAsPost] transaction=Transaction{ fromAccount='123', toAccount='456', amount=17.000000, currency='EUR' }

[onClassifyTransactionEvent] Transaction{ fromAccount='123', toAccount='456', amount=17.000000, currency='EUR' }
  • 2nd instance output will show:
[onClassifyTransactionEvent] Transaction{ fromAccount='123', toAccount='456', amount=17.000000, currency='EUR' }

Both instances are using the console as the standard output as configured on logback.xml.

qbit-event-bus-cluster-sample's People

Contributors

dxps avatar

Stargazers

 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.