All Projects → anair-it → disruptor-billing-example

anair-it / disruptor-billing-example

Licence: other
Example LMAX Disruptor spring-boot project that uses disruptor-spring-manager framework

Programming Languages

java
68154 projects - #9 most used programming language

Projects that are alternatives of or similar to disruptor-billing-example

AyaRay
A Modern C++ Windows-platform physically based renderer developing by Chang Yu.
Stars: ✭ 29 (-48.21%)
Mutual labels:  multithreading
MoltenEngine
A spare-time C# .NET 6 game engine project. Cross-platform, multi-threaded.
Stars: ✭ 113 (+101.79%)
Mutual labels:  multithreading
kafka-workers
Kafka Workers is a client library which unifies records consuming from Kafka and processing them by user-defined WorkerTasks.
Stars: ✭ 30 (-46.43%)
Mutual labels:  multithreading
portable-threads
Portable threads API for Common Lisp (from GBBopen project)
Stars: ✭ 13 (-76.79%)
Mutual labels:  multithreading
Boting
Simple but powerful Telegram Bot library
Stars: ✭ 21 (-62.5%)
Mutual labels:  multithreading
Million-Live-Quintet-Player
IDOLM@STER Million Live! Theater Days Unit Simulation
Stars: ✭ 55 (-1.79%)
Mutual labels:  multithreading
energy management system
energy management system for the microgrid
Stars: ✭ 84 (+50%)
Mutual labels:  multithreading
triple-buffer
Implementation of triple buffering in Rust
Stars: ✭ 66 (+17.86%)
Mutual labels:  multithreading
ECS-Phyllotaxis
Learning ECS - 100k Cubes in Phyllotaxis pattern
Stars: ✭ 17 (-69.64%)
Mutual labels:  multithreading
SoftLight
A shader-based Software Renderer Using The LightSky Framework.
Stars: ✭ 2 (-96.43%)
Mutual labels:  multithreading
Chatroom-in-C
A simple Chatroom built in C programming language. The program is built uses multithreading for handling multiple clients.
Stars: ✭ 51 (-8.93%)
Mutual labels:  multithreading
sphere-mt
C/C++ Multithreading Programming Course Materials.
Stars: ✭ 17 (-69.64%)
Mutual labels:  multithreading
react-native-bg-thread
react-native-bg-thread
Stars: ✭ 45 (-19.64%)
Mutual labels:  multithreading
bsuir-csn-cmsn-helper
Repository containing ready-made laboratory works in the specialty of computing machines, systems and networks
Stars: ✭ 43 (-23.21%)
Mutual labels:  multithreading
ideas4
An Additional 100 Ideas for Computing https://samsquire.github.io/ideas4/
Stars: ✭ 26 (-53.57%)
Mutual labels:  multithreading
Image-Scraper
Fast concurrent image scraper
Stars: ✭ 35 (-37.5%)
Mutual labels:  multithreading
QCircuitFaultEditor
A manager client for IC faults detecting training.
Stars: ✭ 18 (-67.86%)
Mutual labels:  multithreading
TaskManager
A C++14 Task Manager / Scheduler
Stars: ✭ 81 (+44.64%)
Mutual labels:  multithreading
HTTPStaticServer
Bare-bones static HTTP server written in a single C file
Stars: ✭ 24 (-57.14%)
Mutual labels:  multithreading
java-multithread
Códigos feitos para o curso de Multithreading com Java, no canal RinaldoDev do YouTube.
Stars: ✭ 24 (-57.14%)
Mutual labels:  multithreading

Spring Boot managed LMAX Disruptor Example project

This project uses disruptor-spring-manager to create disruptor spring beans and perform message transactions. The project uses spring boot to load up the application as a JMS listener. Integration with IBM Websphere MQ is required to run this project. Ofcourse you can make minor modifications to get this running against ActiveMQ etc.

The example uses 2 disruptor beans. One to process billing records and another to process data streams. Both disruptors are configured as spring beans.

Software pre-requisite

  1. JDK 8+
  2. Maven 3+
  3. Git
  4. IBM Websphere MQ 7.5 server and client jars
  5. Spring boot 1.5.x

Setting up your environment

  1. Create a local queue manager. Name it as you wish.
  2. Create a billing input queue. Name it as your wish.
  3. Create a data stream input queue. Name it as your wish.
  4. Start queue manager
  5. Update src/main/resources/application.yml with queue manager and queue names

Configuring the disruptor

Billing disruptor spring configuration is based on the Consumer Dependency diamond graph that looks like this:

                                       |     journalBillingEventProcessor     |     billingBusinessEventProcessor                 |
                                       |    /                                 |    /                                              |
                                       |   /                                  |   /                                               |
billingEventPublisher -> Ring Buffer ->|  -                                   |  -  corporateBillingBusinessEventProcessor        | -billingOutboundFormattingEventProcessor
                                       |   \                                  |   \                                               |
                                       |    \                                 |    \                                              |
                                       |     billingValidationEventProcessor  |     customerSpecificBillingBusinessEventProcessor |

Data Stream disruptor spring configuration is based on the Consumer Dependency diamond graph that looks like this:

                                          |                                  |    processADataStreamEventProcessor  |
                                          |                                  |   /                                  |
                                          |                                  |  /                                   |
dataStreamEventPublisher -> Ring Buffer ->| - journalBillingEventProcessor   |                                      | -formatDataStreamEventProcessor
                                          |                                  |  \                                   |
                                          |                                  |   \                                  |
                                          |                                  |    processBDataStreamEventProcessor  |

Components

  1. BillingRecord represents a Billing data model.
  2. BillingEvent is used to preload the ringbuffer with BillingRecord objects so that they don't get GCed.
  3. BillingServiceImpl performs billing business logic.
  4. BillingEventPublisher prepares to publish billing records to the ring buffer
  5. BillingEventTranslator actually puts the data in ring buffer
  6. Event Processors/consumers consume off the ring buffer and can perform parallel operations on the data
  7. BillingMessageListener receives the MQ message and calls BillingEventPublisher.
  8. Billing Disruptor bean configuration
  9. Data stream Disruptor bean configuration
  10. Spring configuration files

Run it

1.Start application

mvn clean package
java -jar target/disruptor-billing.jar

You will see the following log messages that prints the disruptor configuration and dependency graph:

15:58:17.269 localhost-startStop-1 INFO [BaseDisruptorConfig] Created and configured LMAX disruptor {Thread Name: billingThread | Ringbuffer slot size: 1024 | Producer type: SINGLE | Wait strategy: BLOCKING}
15:58:17.279 localhost-startStop-1 INFO [DefaultDisruptorConfig]
{JournalBillingEventProcessor | BillingValidationEventProcessor} -> {BillingBusinessEventProcessor | CorporateBillingBusinessEventProcessor | CustomerSpecificBillingBusinessEventProcessor}
{BillingBusinessEventProcessor | CorporateBillingBusinessEventProcessor | CustomerSpecificBillingBusinessEventProcessor} -> {BillingOutboundFormattingEventProcessor}
15:58:17.289 localhost-startStop-1 INFO [JmxDisruptor] disruptor-spring:name=billingDisruptor,type=disruptor MBean defined for Disruptors.

2.Drop a message to any/both input queue. The message should be a long that relays the number of billing messages to be generated and processed. If you put in message of "20", 20 messages will be processed and here is the log output summary:

16:11:37.189 billingListenerContainer-1 INFO [BillingEventTranslator] Published Id [0] to sequence: 0
16:11:37.189 billingListenerContainer-1 INFO [BillingEventTranslator] Published Id [10] to sequence: 10
16:11:37.199 billingThread-1 INFO [BillingValidationEventProcessor] Sequence: 0. Id [0]
16:11:37.269 billingThread-1 INFO [BillingValidationEventProcessor] Sequence: 10. Id [10]
16:11:37.199 billingThread-2 INFO [JournalBillingEventProcessor] Sequence: 0. Id [0]
16:11:37.289 billingThread-3 INFO [BillingBusinessEventProcessor] Sequence: 0. Id [0]
16:11:37.289 billingThread-4 INFO [CustomerSpecificBillingBusinessEventProcessor] Sequence: 0. Id [0]
16:11:37.299 billingThread-5 INFO [CorporateBillingBusinessEventProcessor] Sequence: 0. Id [0]
16:11:37.299 billingThread-2 INFO [JournalBillingEventProcessor] Sequence: 10. Id [10]
16:11:37.309 billingThread-4 INFO [CustomerSpecificBillingBusinessEventProcessor] Sequence: 10. Id [10]
16:11:37.309 billingThread-3 INFO [BillingBusinessEventProcessor] Sequence: 10. Id [10]
16:11:37.309 billingThread-6 INFO [BillingOutboundFormattingEventProcessor] Sequence: 0. Id [0]
16:11:37.309 billingThread-5 INFO [CorporateBillingBusinessEventProcessor] Sequence: 10. Id [10]
16:11:37.310 billingThread-6 INFO [BillingOutboundFormattingEventProcessor] Sequence: 10. Id [10]

JMX

1.On application context startup, all Disruptor beans will be automatically identified and registered as MBeans
2.View Disruptor MBeans through JConsole/Visual VM that looks like: MBean

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].