I have a usecase, where i want to extract the a json tree(state) built in workflow execute method. Following is the sample code.
public class TicketWorkFlowImpl implements TicketWorkFlow {
@Override
public String execute(Step[] steps){
JsonNode resultNode..
//process steps and build resultNode
}
}
After the workflow is executed, there is another api where i want to fetch the result. I want to use replay or history to fetch the resultNode.
One solution i am thinking is to use the history of events and fetch from the events data
GetWorkflowExecutionHistoryRequest request = getWorkflowExecutionHistoryRequest(workFlowId);
GetWorkflowExecutionHistoryResponse resultHistory =
service.blockingStub().getWorkflowExecutionHistory(request);
Stream<HistoryEvent> events = resultHistory.getHistory().getEventsList().stream();
But as this is not used as activity input or output parametr i can not get the same.
The second solution i see is create a dummy Activity and pass the resultNode so that it is stored as part of events data.
public class TicketWorkFlowImpl implements TicketWorkFlow {
@Override
public String execute(Step[] steps){
JsonNode resultNode..
//process steps and build resultNode
CallResultActivity.record(resultNode)//This is a temporal activity
}
}
Are there any better ways for the usecase mentioned? Are there any drawbacks with the second solution