Skip to content

Commit

Permalink
Improve WorkflowTaskExecutor logic to create a
Browse files Browse the repository at this point in the history
failed task instead of raising an Exception
  • Loading branch information
gardusig committed May 11, 2023
1 parent 31aec6b commit 0b01347
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions Conductor/Client/Worker/WorkflowTaskExecutor.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Conductor.Client.Interfaces;
using Conductor.Client.Extensions;
using Microsoft.Extensions.Logging;
using System;
using System.Collections.Generic;
Expand Down Expand Up @@ -140,15 +141,14 @@ private void ProcessTask(Models.Task task)
try
{
var taskResult = _worker.Execute(task);
taskResult.WorkerId = _workerSettings.WorkerId;
UpdateTask(taskResult);
_logger.LogTrace(
$"[{_workerSettings.WorkerId}] Done processing task for worker"
+ $", taskType: {_worker.TaskType}"
+ $", domain: {_workerSettings.Domain}"
+ $", taskId: {task.TaskId}"
+ $", workflowId: {task.WorkflowInstanceId}"
);
UpdateTask(taskResult);
}
catch (Exception e)
{
Expand All @@ -159,6 +159,8 @@ private void ProcessTask(Models.Task task)
+ $", taskId: {task.TaskId}"
+ $", workflowId: {task.WorkflowInstanceId}"
);
var taskResult = task.Failed(e.Message);
UpdateTask(taskResult);
}
finally
{
Expand All @@ -168,6 +170,7 @@ private void ProcessTask(Models.Task task)

private void UpdateTask(Models.TaskResult taskResult)
{
taskResult.WorkerId = taskResult.WorkerId ?? _workerSettings.WorkerId;
for (var attemptCounter = 0; attemptCounter < UPDATE_TASK_RETRY_COUNT_LIMIT; attemptCounter += 1)
{
try
Expand Down

0 comments on commit 0b01347

Please sign in to comment.