Skip to main content

External Events

info

Before you can use an ExternalEventDef in a WfSpec, you need to create the ExternalEventDef metadata object in LittleHorse. You can do that following our metadata management docs.

You can use WorkflowThread#WaitForEvent() to add an EXTERNAL_EVENT Node that causes the WfRun to block until an ExternalEvent arrives. It's simple:

public void threadFunction(WorkflowThread thread) {
NodeOutput eventOutput = thread.waitForEvent("my-event-name");
}

Accessing Event Content

Lastly, just as with TASK nodes you can use the NodeOutput from WorkflowThread::waitForEvent() to mutate a WfRunVariable:

public void threadFunction(WorkflowThread thread) {
WfRunVariable myVar = thread.addVariable("my-var", VariableType.JSON_OBJ);
NodeOutput eventOutput = thread.waitForEvent("my-event-name");
thread.mutate(myVar, VariableMutationType.ASSIGN, eventOutput);
}
note

If you use an ExternalEventDef for any EXTERNAL_EVENT node as shown in this tutorial, you cannot re-use that ExternalEventDef as a trigger for Interrupts.