Skip to content

Latest commit

 

History

History

schedulablestate-heartbeat

Heartbeat -- Schedulablestate

This CorDapp is a simple showcase of scheduled activities (i.e. activities started by a node at a specific time without direct input from the node owner).

Concepts

Flows

A node starts its com.heartbeat by calling the StartHeartbeatFlow. This creates a HeartState on the ledger. This HeartState has a scheduled activity to start the HeatbeatFlow one second later.

When the HeartbeatFlow runs one second later, it consumes the existing HeartState and creates a new HeartState. The new HeartState also has a scheduled activity to start the HeatbeatFlow in one second.

In this way, calling the StartHeartbeatFlow creates an endless chain of HeartbeatFlows one second apart.

Usage

Pre-Requisites

For development environment setup, please refer to: Setup Guide.

Running the CorDapp

Open a terminal and go to the project root directory and type: (to deploy the nodes using bootstrapper)

./gradlew clean build deployNodes

Then type: (to run the nodes)

./build/nodes/runnodes

Interacting with the nodes:

Go to the interactive node shell for PartyA, and run the StartHeatbeatFlow:

start StartHeartbeatFlow

If you now start monitoring the node's flow activity...

flow watch

...you will see the Heartbeat flow running every second until you close the Flow Watch window using ctrl/cmd + c:

xxxxxxxx-xxxx-xxxx-xx Heartbeat xxxxxxxxxxxxxxxxxxxx Lub-dub