I have this code:
@Saga
@Slf4j
public class ActionsSaga2 {
@Autowired
transient CommandGateway commandGateway;
@Autowired
transient ActionService actionService;
String id;
ApplicationState state;
@StartSaga
@SagaEventHandler(associationProperty = "applicationId")
public void on(ApplicationCreatedEvent event) {
id = event.getApplicationId();
state = event.getState();
commandGateway.send(ScheduleActionCommand.builder()
.applicationId(event.getApplicationId())
.actionId(id)
.targetState(event.getState())
.build());
}
@EndSaga
@SagaEventHandler(associationProperty = "applicationId")
public void on(ActionDoneEvent event) {
assert id != null;
}
}
First @SagaEventHandler on(ApplicationCreatedEvent event) sets the private fields id and state.
But in the second @SagaEventHandler on(ActionDoneEvent event) both properties are null.
I'm pretty sure that the calls are routed to the same saga (the only record in saga_entry that is deleted after the second method call)
Could you help me where is the problem?
I have no special configuration for saga, using AxonServer and Spring boot