SAGA - private properties null accros @SagaEventHandler methods

Hello,

The properties are null accros @SagaEventHandler methods

The First @SagaEventHandler on(NeedExpressedEvent needExpressedEvent) sets the private fields operationId and planningId .

But in the second @SagaEventHandler on(DatesAddedToPlanningEvent datesAddedToPlanningEvent) operationId property is null.

@Saga
public class MySaga {

    @Autowired
    private transient CommandGateway commandGateway;
    private OperationId operationId;
    private PlanningId planningId;

    public static final String OPERATION_ID_ASSOCIATION = "operationId";
    public static final String PLANNING_ID_ASSOCIATION = "planningId";

    @StartSaga
    @SagaEventHandler(associationProperty = OPERATION_ID_ASSOCIATION )
    public void handle(NeedExpressedEvent needExpressedEvent, UUIDProvider uuidProvider){
        System.out.println("Saga  start !!!");
        this.operationId = needExpressedEvent.getOperationId();
        this.planningId = needExpressedEvent.getPlanningId();
        SagaLifecycle.associateWith(PLANNING_ID_ASSOCIATION, planningId.toString());
        commandGateway.send(new AddDatesToPlanningCommand(planningId,needExpressedEvent.getDebut(),needExpressedEvent.getFin()));
    }

    @SagaEventHandler(associationProperty = PLANNING_ID_ASSOCIATION)
    public void handle(DatesAddedToPlanningEvent datesAddedToPlanningEvent){
        System.out.println("operation Id " + this.operationId);
        commandGateway.send(new UpdateStateCommand(this.operationId, Etat.INFO_DO_OK));
    }

    @SagaEventHandler(associationProperty = OPERATION_ID_ASSOCIATION)
    public void handle(StateUpdatedEvent stateUpdatedEvent){
        System.out.println("Saga stop !!!");
        SagaLifecycle.end();
    }

}

Could you help me ?

Hi Vincent, could it be you use Jackson, in which case private fields might not be serialized? The easiest fix, in that case, would be to add getters for the private fields.

Hi Gerard,

Yes, I use Jackson
I add getters and it’s work perfectly !
Thanks a lot !