Skip to main content

Events

There are several events dispatched in the execution of a process. There is a start and end process events that can be observed for managing processes themselves. There are before and after node events that gets dispatched for each node. These can be used for cycle detection, debugging, or telemetry.

Events Namespace

  • ProcessStartEvent - Dispatched before a process runs
  • ProcessEndEvent - Dispatched after a process runs
  • ProcessNodeBeforeEvent - Dispatched before a node is processed
  • ProcessNodeAfterEvent - Dispatched after a node is processed
  • ProcessExceptionEvent - Dispatched if there is an exceptinon. Note, this is process engine dependent
  • ProcessNodeNotifyEvent - Dispatched by a node if its needs to notify the event dispatcher.

CycleDetectionProcessSubscriber

See CycleDetectionProcessSubscriber

The Feral Slack package contains a cycle detection class that listens for nodes that are processed more times than they should. The Cycle Detection class is a process subscriber that subcribes to the StartProcess and BeforeNode events.

    public static function getSubscribedEvents(): array
{
return [
ProcessStartEvent::class => ['onStartProcess'],
ProcessNodeBeforeEvent::class => ['onBeforeNode']
];
}

LoggerProcessSubscriber

See LoggerProcessSubscriber

The logger process subscriber listens for the process events and logs them to the PSR logger interface.

    public static function getSubscribedEvents(): array
{
return [
ProcessStartEvent::class => ['onStartProcess'],
ProcessEndEvent::class => ['onEndProcess'],
ProcessNodeBeforeEvent::class => ['onBeforeNode'],
ProcessNodeAfterEvent::class => ['onAfterNode'],
ProcessExceptionEvent::class => ['onProcessException'],
ProcessNodeNotifyEvent::class => ['onNodeNotify'],
];
}

ProfilerProcessSubscriber

See ProfilerProcessSubscriber

The profiler's subscriber is used with Symfony to show the process flow in the Symfony Profiler. This is used for debugging only.

Profiler Example

    public static function getSubscribedEvents(): array
{
return [
ProcessStartEvent::class => ['onStartEvent'],
ProcessEndEvent::class => ['onEndEvent'],
ProcessNodeBeforeEvent::class => ['onNodeBeforeEvent'],
ProcessNodeAfterEvent::class => ['onNodeAfterEvent']
];
}