Skip to content

myawnhc/BankInABox

Repository files navigation

BankInABox

This is a simple implementation of a Retail Banking application, intended to show features of Hazelcast IMDG and Hazelcast Jet being used cooperatively.

The initial implementation is focused on Fraud Detection. In IMDG, an Executor-based RuleEngine is used to execute RuleSets; each RuleSet consists of a set of rules and then an aggregation of the rule results into an overall pass/fail score. Two rulesets are currently in place; one for Location based rules and one for Merchant based rules.

One-time setup:

You'll need to have the following dependencies installed in order to run this demo.

  • Java JDK 11 or later
  • maven
  • docker

Once you have the project installed (cloned from github), you'll need to build it.

mvn clean package

(Or use your favorite IDE to build the top-level project).

Note that the project requires JDK 11 or later to build.

Start MariaDB (Docker Image)

When running, the demo operates all in-memory, but the data is originally loaded from a MariaDB database. To simplify running the demo, there is a Docker image that includes MariaDB and test data for running the demo. To start MariaDB running in a Docker image, do the following:

For MacOS, this can be done as follows

cd mariadb
make up
lsof -i : 3306

The last line is optional but a good check -- you should see that the docker copy of MariaDB is listening on port 3306. (For compatibility, MariaDB identifies itself as MySQL on the output)

Start IMDG Cluster:

First, start one or more IMDG Cluster nodes using the script runImdg.sh

./runImdg.sh

I generally start 3 nodes. Earlier versions of the demo required this because some features of the CP Subsystem were used, but the current version can run with a single IMDG if desired.

Start Jet Cluster

Start one or more Jet Cluster nodes using the script runJet.sh

./runJet.sh

A single node here should be sufficient.

Start Grafana

You should also start the Grafana dashboard in order to observe the output generated by the demo. From the top-level BankInABox directory

make up

You can then point a browser to https://localhost:80 and log in with the default username and password.

First time setup

The first time you start Grafana you'll need to import the customized BankInABox dashboard. Select the Grafana icon (Upper left corner of the screen), the Dashboards menu, and select Import from the pop-out submenu.

In the import dialog, click the box that says Import JSON file, and navigate to the dashboard file location

[BankInABox home]/grafana/Bank In A Box-dashboard.json

Once the dashboard is imported, you can go to the Grafana home page and then select the dashboard from the list of installed dashboards. All the gauges will be reading zero until the demo begins.

Start the demo (Launcher script)

Finally, start the demo itself by running the following script in the top-level BankInABox directory

./runLauncher.sh

The launcher script runs the main Launcher class in the demo application, which does all of the following:

  • Triggers a preload of the Merchant and Account info from the database into the data grid
  • Sets a listener on the preAuth map to detect incoming transactions. The listener forwards trasactions to each RuleSet Executor by writing the transaction to a ruleset specific Queue.
  • Creates a Jet pipeline to monitor the incoming transaction stream and aggregate the average transaction amount by merchant, and submits a job to the Jet cluster to execute the pipeline.
  • Starts executors for each RuleSet (current demo has two)
  • Starts an executor to aggregate completed RuleSet results
  • Starts a periodic task (5 second interval) that writes data to the Graphite sink used by the Grafana dashboard to show results.
  • Loads data from the database Transaction table into the preAuth map; this then triggers the listener and Jet pipeline to begin processing.

The Grafana dashboard you started earlier can be used to monitor the transaction results; you can see the transaction volume, fraud rate, and average latency per transaction. (Note that there is a warm-up time for the demo due to the initial database load; the latency will start high but then drop down as the maps get populated.)

Hazelcast Management Center can be used to monitor the maps and watch how data moves between the maps. (Generated transactions go into the preAuth map; once they have been processed they will move to either approved, rejectedForCredit, or rejectedForFraud).

Jet Management Center can be used to monitor the Jet pipeline job. The pipeline watches the transaction stream and calculates updated average transaction amounts per merchant. The Jet Management Center startup script needs to be modified to connect to port 5710 rather than default 5701, so that Jet and IMDG can run on the same server without collision.