Early Signal should be ignored

Heya guys,

wanted to see if there is different approach than this and if this IS the best way of going about it.

Signal can be sent to a workflow definition at any time to approve/reject the process…it should only be available when the process has finished doing background work aka fetching data…etc

how to ignore/dismiss an early Signal? is there a better alternative than this?

mitigating STATE

@SignalMethod
public void approve() {
    if (state != State.WAITING_FOR_APPROVAL) {
        Workflow.getLogger(getClass()).info("Approval received too early. Ignoring.");
        return;
    }

    approved = true;
}

ty

What you are doing is ok if you are sure another approval/reject signal is going to come in later.
Otherwise you can store its delivery in workflow state and then act upon it later in process.

Thanks Tihomir, I did try that aswell but, with 100% assurety will will get another signal later on so went for that original option