Skip to Content
EngineErweiterungenNotification Handler

Notification Handler

Der Notification Handler ermoeglicht es, auf Benachrichtigungen der Engine zu reagieren und eigene Logik auszufuehren.

Funktionsweise

Die Engine sendet bei bestimmten Ereignissen Notifications. Mit dem Notification Handler koennen Extensions auf diese Ereignisse subscriben.

Verfuegbare Notifications

MethodeEreignisAnwendungsfall
onProcessStartedProzessinstanz gestartetLogging, Audit-Trail
onProcessFinishedProzessinstanz erfolgreich beendetBenachrichtigungen, Cleanup
onProcessErrorProzessinstanz mit Fehler beendetAlerting, Incident-Management
onUserTaskWaitingUser Task wartet auf BearbeitungE-Mail-Benachrichtigung, Push-Notification
onUserTaskFinishedUser Task abgeschlossenLogging, naechste Schritte triggern

Beispiel: Alle Events loggen

import { Engine } from '@5minds/processcube_engine_sdk'; export function onLoad(engineObject: Engine) { engineObject.notifications.onProcessStarted((notification) => { console.log('Prozess gestartet:', notification.processModelId, notification.processInstanceId); }); engineObject.notifications.onProcessFinished((notification) => { console.log('Prozess beendet:', notification.processModelId, notification.processInstanceId); }); engineObject.notifications.onProcessError((notification) => { console.error('Prozess-Fehler:', notification.processModelId, notification.error); }); engineObject.notifications.onUserTaskWaiting((notification) => { console.log('User Task wartet:', notification.flowNodeId, notification.processInstanceId); }); engineObject.notifications.onUserTaskFinished((notification) => { console.log('User Task beendet:', notification.flowNodeId, notification.processInstanceId); }); }

Beispiel: E-Mail bei User Task

import { Engine } from '@5minds/processcube_engine_sdk'; export function onLoad(engineObject: Engine) { engineObject.notifications.onUserTaskWaiting(async (notification) => { const assignedUsers = notification.assignedUsers ?? []; for (const userId of assignedUsers) { await sendEmail({ to: `${userId}@company.com`, subject: `Neue Aufgabe: ${notification.flowNodeName}`, body: `Sie haben eine neue Aufgabe im Prozess ${notification.processModelId}.`, }); } }); }

Die Notification-Callbacks werden asynchron ausgefuehrt und blockieren nicht die Prozessausfuehrung. Fehler in Callbacks fuehren nicht zum Abbruch des Prozesses.

Abgrenzung zu anderen Extensions

ExtensionZweck
Notification HandlerReagieren auf Engine-Events innerhalb der Engine
RabbitMQEvents an externe Systeme weiterleiten
MonitoringMetriken aggregieren und exportieren