Repository navigation
Open
Labels
Priority 1: MustHighest priority. A release cannot be made if this issue isn’t resolved.Highest priority. A release cannot be made if this issue isn’t resolved.
Milestone
Description
Why
Today a workflow that needs a guarded decision on event-sourced state has to dispatch a command to a
separate command handler, even when the decision belongs to the process itself. That adds a command
type, a handler and a round trip per decision.
We want an execute step that does what a command handler does, inside the workflow:
- Better integration with Axon Framework 5. The step uses the same
StateManagerand
EventAppenderas a command handler, so appended events carry the entity's consistency condition. - Less clutter. No extra command type and handler for decisions that only the workflow makes.
- Decision logic inside the process. The guard and the event live in the step that needs them.
- No repeated command-send pattern where it is not needed. Commands stay the tool for decisions
owned by another component.
Proposed API
ctx.execute("enroll", CourseState.class, courseId, (course, appender) -> {
if (course.isFull()) { return; }
appender.append(new StudentEnrolled(courseId, studentId));
}).await();The appender is only available together with the loaded entity. That keeps this separate from
publish, which records workflow progress and is not guarded by any entity.
Implementation
A thin overload over the existing execute(stepName, (processingContext, payload) -> ...). Each execute
step already runs in its own unit of work with a fresh event store transaction, so no engine change
is needed:
public <T> WorkflowStepResult execute(String stepName,
Class<T> entityType,
Object entityId,
BiConsumer<T, EventAppender> decision) {
return execute(stepName, (processingContext, payload) -> {
T entity = FutureUtils.joinAndUnwrap(processingContext.component(StateManager.class)
.loadEntity(entityType, entityId, processingContext));
decision.accept(entity, EventAppender.forContext(processingContext));
return Map.of();
});
}Metadata
Metadata
Assignees
Labels
Priority 1: MustHighest priority. A release cannot be made if this issue isn’t resolved.Highest priority. A release cannot be made if this issue isn’t resolved.
Activity
[-]Workflow execute step that loads an event-sourced entity and appends events guarded by it[/-][+]Workflow step with entity state and event appender[/+]smcvb commentedon Nov 17, 2026
Relates to #172