3535
3636import java .util .Optional ;
3737
38+ import lombok .extern .slf4j .Slf4j ;
39+
3840import org .springframework .beans .factory .annotation .Autowired ;
3941import org .springframework .stereotype .Component ;
4042
4143@ Component
44+ @ Slf4j
4245public class TaskResultEventHandler implements TaskEventHandler {
4346
4447 @ Autowired
@@ -99,11 +102,13 @@ public void handleTaskEvent(TaskEvent taskEvent) throws TaskEventHandleError, Ta
99102 taskInstance .setVarPool (taskEvent .getVarPool ());
100103 processService .changeOutParam (taskInstance );
101104 taskInstanceDao .updateById (taskInstance );
102- sendAckToWorker (taskEvent );
103105 } catch (Exception ex ) {
104106 TaskInstanceUtils .copyTaskInstance (oldTaskInstance , taskInstance );
105107 throw new TaskEventHandleError ("Handle task result event error, save taskInstance to db error" , ex );
106108 }
109+
110+ sendAckToWorker (taskEvent );
111+
107112 TaskStateEvent stateEvent = TaskStateEvent .builder ()
108113 .processInstanceId (taskEvent .getProcessInstanceId ())
109114 .taskInstanceId (taskEvent .getTaskInstanceId ())
@@ -115,11 +120,16 @@ public void handleTaskEvent(TaskEvent taskEvent) throws TaskEventHandleError, Ta
115120 }
116121
117122 public void sendAckToWorker (TaskEvent taskEvent ) {
118- ITaskInstanceExecutionEventAckListener instanceExecutionEventAckListener =
119- SingletonJdkDynamicRpcClientProxyFactory
120- .getProxyClient (taskEvent .getWorkerAddress (), ITaskInstanceExecutionEventAckListener .class );
121- instanceExecutionEventAckListener .handleTaskInstanceExecutionFinishEventAck (
122- TaskInstanceExecutionFinishEventAck .success (taskEvent .getTaskInstanceId ()));
123+ try {
124+ ITaskInstanceExecutionEventAckListener instanceExecutionEventAckListener =
125+ SingletonJdkDynamicRpcClientProxyFactory
126+ .getProxyClient (taskEvent .getWorkerAddress (), ITaskInstanceExecutionEventAckListener .class );
127+ instanceExecutionEventAckListener .handleTaskInstanceExecutionFinishEventAck (
128+ TaskInstanceExecutionFinishEventAck .success (taskEvent .getTaskInstanceId ()));
129+ } catch (Exception e ) {
130+ // master ignore the exception, worker will retry to send this TaskEventType.RESULT event again.
131+ log .warn ("send ack to worker error, taskInstanceId: {}" , taskEvent .getTaskInstanceId (), e );
132+ }
123133 }
124134
125135 @ Override
0 commit comments