Hello,
I have a single workflow which looks like this:
public class MyWorkFlowImpl implements MyWorkWorkFlow {
Customer customer;
private final ActivityOptions options =
ActivityOptions.newBuilder()
.setStartToCloseTimeout(Duration.ofHours(1))
.setRetryOptions(RetryOptions.newBuilder().setMaximumAttempts(1).build())
.build();
private final MyActivities activities =
Workflow.newActivityStub(MyActivities.class, options);
@Override
public void startWorkflow(Customer customer) {
try {
this.customer = customer;
activities.task1(customer)
activities.task2(customer);
}
catch (ActivityFailure e) {
}
}
@Override
public void cancelOrTerminateWorkflow() { // a signal method
// cancel when Request cancellation signal is sent from UI
// some logic to be performed
}
@Override
public void setCustomer(Customer customer) { // signal
this.customer = customer;
}
}
When I send a cancellation request from UI ( attached screenshot),
Doesn’t matter under which activity I’m in, I just want it to be redirected to a signal method “cancelWorkflow” or any method/activity if possible and execute the logic inside it.
Similarly something to be done for “terminate” signal from UI
Is there any example to handle these signals sent from UI inside a workflow using java sdk?