[fix]修正无法接收处理错误结果的bug

This commit is contained in:
大石头 2024-07-11 15:32:58 +08:00
parent 1b869ae13f
commit 6a25c7dafa
2 changed files with 11 additions and 3 deletions

View File

@ -421,7 +421,7 @@ public class JobService(AppService appService, ICacheProvider cacheProvider, ITr
var traceId = result.TraceId ?? DefaultSpan.Current + "";
// 已终结的任务,汇总统计
if (result.Status is JobStatus. or JobStatus.)
if (result.Status is JobStatus.)
{
task.Times++;
@ -432,13 +432,17 @@ public class JobService(AppService appService, ICacheProvider cacheProvider, ITr
}
else if (result.Status == JobStatus.)
{
SetJobError(job, task);
task.Times++;
task.Error++;
//ji.Message = err.Message;
SetJobError(job, task);
// 出错时判断如果超过最大错误数,则停止作业
CheckMaxError(app, job);
// 记录状态
_appService.UpdateOnline(app, task, ip);
}
else if (result.Status == JobStatus.)
{

View File

@ -1,6 +1,7 @@
using System;
using System.ComponentModel;
using AntJob;
using NewLife.Security;
namespace HisAgent;
@ -21,6 +22,9 @@ internal class HelloJob : Handler
var time = ctx.Task.DataTime;
WriteLog("新生命蚂蚁调度系统!当前任务时间:{0}", time);
// 一定几率抛出异常
if (Rand.Next(2) == 0) throw new Exception("Error");
// 成功处理数据量
return 1;
}