Skip to main content

nexora-event

Sealed event hierarchy and in-process event bus. Subscribe to observe execution lifecycle events without coupling to internal engine state.

Event types

All events extend ExecutionEvent.

Plan lifecycle

EventFired when
PlanStartedEventEngine begins executing a plan
PlanCompletedEventAll steps finished successfully
PlanFailedEventOne or more steps failed and execution halted
PlanAmendedEventA step returned an amendment (add/skip/modify)

Step lifecycle

EventFired when
StepStartedEventA step begins execution
StepCompletedEventA step finishes successfully
StepFailedEventA step throws or returns a failure result

Saga compensation

EventFired when
CompensationStartedEventSaga rollback begins for a step
CompensationCompletedEventA compensation capability succeeded
CompensationFailedEventA compensation capability failed (execution continues for remaining compensations)

Plugin lifecycle

EventFired when
PluginActivatedEventA plugin successfully initializes
PluginDeactivatedEventA plugin shuts down

Subscribing to events

Subscribe via NexoraEngine:

NexoraEngine engine = NexoraEngine.builder()
.withPlugin(myPlugin)
.build();

// Subscribe before executing
Subscription sub = engine.subscribe(event -> {
switch (event) {
case PlanStartedEvent e ->
log.info("Plan started: executionId={}", e.executionId());
case StepFailedEvent e ->
metrics.increment("step.failed", "capability", e.capabilityId());
case PlanAmendedEvent e ->
log.debug("Amendment: type={} step={}", e.amendmentType(), e.stepId());
default -> {}
}
});

// Unsubscribe when done
sub.cancel();

InProcessEventBus

The default ExecutionEventBus implementation. Dispatches events synchronously on the calling thread. Subscriber exceptions are caught and logged; they do not affect execution.

Provide a custom ExecutionEventBus implementation to fan out to Kafka, a metrics pipeline, or any external system:

public class KafkaEventBus implements ExecutionEventBus {
@Override
public Subscription subscribe(EventHandler<ExecutionEvent> handler) { ... }

@Override
public void publish(ExecutionEvent event) {
kafkaProducer.send(serialize(event));
}
}