Monitors are Java or Kotlin assets that are triggered at designated points in a process, activity, task or service lifecycle. Depending on what it's interested in, a monitor implements one of these interfaces:
A monitor must identify itself with the@Monitor
annotation, whose value is the monitor name and which includes the mandatory
"category" attribute to designate its type. Here's an example:
@Monitor(value="Activity Timing", category=ActivityMonitor.class) public class ActivityTimingMonitor implements ActivityMonitor { @Override public Map<String,Object> onStart(ActivityRuntimeContext context) { context.logDebug("Start: " + Instant.now()); return null; } }
Annotated monitors are not enabled by default unless the "defaultEnabled" annotation attribute is specified as true. Monitors can be turned on and off in the Configurator Monitoring tab in MDW Studio or MDWHub. See the example depicted in the screenshot below.
NOTE:Because monitors are meant to be dynamic, in-flight (non-latest versioned) instances of processes and activities will use the monitor attributes from the latest definition (if present).
Any monitor asset you create with the proper annotations will appear in the Monitoring tab list for its designated elements.
Generally, monitors have the ability to change outcomes (in the sample code above the onStart()
method
can return a map of process variable names/values to update). This means a monitor usually runs synchronously.
However, some monitors only need to perform notifications or other actions that can take place asynchronously and
should not slow down workflow/service execution. Such a monitor can implement the
OfflineMonitor
interface to be fired asynchronously.