Spring Reactive state machine transition on entry function error #1013
yogeshpandey
started this conversation in
General
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
@jvalkeal How can we enable state machines to throw errors or not accept an event. if the state entry function fails?
example:
states
.withStates()
.initial(OrderState.START)
.end(OrderState.CREATED)
.stateEntryFunction(OrderState.CREATED, reactiveCreateActionHandler);
transitions
.withExternal()
.source(OrderState.START)
.target(OrderState.CREATED)
.event(OrderEvent.CREATE);
current behaviour:
stateMachine.sendEvent(Mono.just(msg))
.collectList()
.flatMap(stateMachineEventResults -> {
if(stateMachineEventResults.get(0).getResultType() != StateMachineEventResult.ResultType.ACCEPTED) {
return Mono.error(new OrderStateMachineException(
new OrderIdentifier(order.getTenantId(), order.getExternalOrderId()),
stateMachine.getState().getId(),
msg.getPayload()));
}else{
return Mono.just(((Order)
stateMachine.getExtendedState().getVariables().get(OrderStateMachineFactory.ORDER_OBJECT)));
}
});
The event CREATE triggers the state transition even if the reactiveCreateActionHandler function fails, how can we prevent the transition
Beta Was this translation helpful? Give feedback.
All reactions