I have a workflow using java-sdk like this
public class MyWorkflowImpl implements MyWorkflow {
@Override
public void startMyWorkflowImpl() {
try {
activityA();
// change workflow status to success in our own mysql db(not temporal cluster db)
activityB("success");
} catch (Exception e) {
// change workflow status to failed in our own mysql db(not temporal cluster db)
activityB("failed");
}
}
}
I got a question about termination/cancellation about this workflow. If the activityA runs with unlimited retry, I want to terminate/cancel the workflow manually. The tricky thing is that after terminate/cancel the workflow, I still need to run activityB to change the workflow status in the db(business service db, not temporal cluster db).
I come up with 2 options to do so:
Option1: I will write a script to cancel the workflow. When workflow is canceled, the exception could be gotten by try…catch, then activityB() will run to change status to “failed”. The drawback of this option is that I need to change some code in workflow, like I need to add heart-beat in activityA(), and the feedback of this operation will not be so timely.
Option2: I will add an endpoint to terminate the workflow, the logic of the endpoint is like terminate workflow -> change status in db
.
I’m a little confused about these 2 options, any help is much appreciable!