From 9cda9ae8e840f6b30e3db06235a0efced6def378 Mon Sep 17 00:00:00 2001 From: Demis Bellot Date: Wed, 27 Mar 2024 13:40:51 +0800 Subject: [PATCH] Update BackgroundMqServices.cs --- .../BackgroundMqServices.cs | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/MyApp.ServiceInterface/BackgroundMqServices.cs b/MyApp.ServiceInterface/BackgroundMqServices.cs index 26e8926..14ecb8e 100644 --- a/MyApp.ServiceInterface/BackgroundMqServices.cs +++ b/MyApp.ServiceInterface/BackgroundMqServices.cs @@ -121,15 +121,18 @@ public async Task Any(DbWrites request) }, x => x.PostId == request.FailJob.Id); var postJob = await Db.SingleByIdAsync(request.FailJob.Id); - if (postJob.RetryCount > 3) + if (postJob != null) { - await Db.UpdateOnlyAsync(() => - new PostJob { CompletedDate = DateTime.UtcNow }, - x => x.PostId == request.FailJob.Id); - } - else - { - modelWorkers.Enqueue(postJob); + if (postJob.RetryCount > 3) + { + await Db.UpdateOnlyAsync(() => + new PostJob { CompletedDate = DateTime.UtcNow }, + x => x.PostId == request.FailJob.Id); + } + else + { + modelWorkers.Enqueue(postJob); + } } }