Browse Source
Merge pull request #472 from colinin/5.1.1
fix(tasks): 无需对周期性作业改变状态
pull/474/head
yx lin
4 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with
23 additions and
13 deletions
-
apps/vue/src/views/task-management/background-jobs/components/BackgroundJobInfoModal.vue
-
aspnet-core/modules/task-management/LINGYUN.Abp.BackgroundTasks/LINGYUN/Abp/BackgroundTasks/Internal/JobExecutedEvent.cs
|
|
|
@ -139,6 +139,8 @@ |
|
|
|
isEnabled: true, |
|
|
|
priority: JobPriority.Normal, |
|
|
|
jobType: JobType.Once, |
|
|
|
maxCount: 0, |
|
|
|
maxTryCount: 0, |
|
|
|
args: {}, |
|
|
|
} as BackgroundJobInfo); |
|
|
|
const [registerModal, { closeModal, changeOkLoading }] = useModalInner((model) => { |
|
|
|
@ -282,6 +284,8 @@ |
|
|
|
isEnabled: true, |
|
|
|
priority: JobPriority.Normal, |
|
|
|
jobType: JobType.Once, |
|
|
|
maxCount: 0, |
|
|
|
maxTryCount: 0, |
|
|
|
args: {}, |
|
|
|
} as BackgroundJobInfo; |
|
|
|
}); |
|
|
|
|
|
|
|
@ -37,10 +37,13 @@ public class JobExecutedEvent : JobEventBase<JobExecutedEvent>, ITransientDepend |
|
|
|
{ |
|
|
|
job.TryCount += 1; |
|
|
|
job.IsAbandoned = false; |
|
|
|
// 将任务标记为运行中, 会被轮询重新进入队列
|
|
|
|
job.Status = JobStatus.FailedRetry; |
|
|
|
job.Result = GetExceptionMessage(context.EventData.Exception); |
|
|
|
|
|
|
|
// 周期性任务不用改变重试策略
|
|
|
|
if (job.JobType != JobType.Period) |
|
|
|
{ |
|
|
|
// 将任务标记为运行中, 会被轮询重新进入队列
|
|
|
|
job.Status = JobStatus.FailedRetry; |
|
|
|
// 多次异常后需要重新计算优先级
|
|
|
|
if (job.TryCount <= (job.MaxTryCount / 2) && |
|
|
|
job.TryCount > (job.MaxTryCount / 3)) |
|
|
|
@ -51,16 +54,19 @@ public class JobExecutedEvent : JobEventBase<JobExecutedEvent>, ITransientDepend |
|
|
|
{ |
|
|
|
job.Priority = JobPriority.Low; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if (job.TryCount >= job.MaxTryCount) |
|
|
|
// 当未设置最大重试次数时不会标记停止
|
|
|
|
if (job.MaxTryCount > 0 && job.TryCount >= job.MaxTryCount) |
|
|
|
{ |
|
|
|
job.Status = JobStatus.Stopped; |
|
|
|
job.IsAbandoned = true; |
|
|
|
job.NextRunTime = null; |
|
|
|
await RemoveJobAsync(context, job); |
|
|
|
// 重试达到上限发布异常通知
|
|
|
|
await NotifierAsync(context, job); |
|
|
|
} |
|
|
|
|
|
|
|
// 每次重试发布异常通知
|
|
|
|
await NotifierAsync(context, job); |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
|