Hello,
I have a use case where we need to publish events whenever a new workflow started and completed.
We used a class which extends WorkflowInboundCallsInterceptorBase to achieve this
Code as below
public class TestWorkflowInboundInterceptor extends WorkflowInboundCallsInterceptorBase {
private WorkflowInfo workflowInfo;
public TestWorkflowInboundInterceptor(WorkflowInboundCallsInterceptor next) {
super(next);
this.workflowInfo = Workflow.getInfo();
}
@Override
public WorkflowOutput execute(WorkflowInput input) {
log.info("Workflow Started");
//Publish Events saying workflow started
WorkflowOutput output = null;
try {
output = super.execute(input);
log.info("Workflow Output Response: {} ", output.getResult());
//Publish Events saying workflow Completed
log.info("Workflow Completed");
} catch (Exception e) {
log.info("Workflow Failed");
//Publish Events saying workflow Failed
throw e;
}
}
}
Our code is deployed in multinode architecture ( worker running in 8 nodes) .
Ideally whenever we send a new WF request i should be seeing only one Workflow Started and one Workflow Completed/Workflow Failed. but we are noticing the
interceptor is being called multiple times and the events are published multiple times , in some case multiple times in the same node