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); + } } }