Skip to content

Commit

Permalink
implement RetryCount on PostJob
Browse files Browse the repository at this point in the history
  • Loading branch information
mythz committed Mar 27, 2024
1 parent f4ba231 commit 4ce37bf
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
15 changes: 13 additions & 2 deletions MyApp.ServiceInterface/BackgroundMqServices.cs
Original file line number Diff line number Diff line change
Expand Up @@ -114,11 +114,22 @@ public async Task Any(DbWrites request)

if (request.FailJob != null)
{
await Db.UpdateOnlyAsync(() => new PostJob {
CompletedDate = DateTime.UtcNow,
await Db.UpdateAddAsync(() => new PostJob {
Error = request.FailJob.Error,
RetryCount = 1,
},
x => x.PostId == request.FailJob.Id);
var postJob = await Db.SingleByIdAsync<PostJob>(request.FailJob.Id);
if (postJob.RetryCount > 3)
{
await Db.UpdateOnlyAsync(() =>
new PostJob { CompletedDate = DateTime.UtcNow },
x => x.PostId == request.FailJob.Id);
}
else
{
modelWorkers.Enqueue(postJob);
}
}

if (request.AnswerAddedToPost != null)
Expand Down
1 change: 1 addition & 0 deletions MyApp.ServiceModel/Posts.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ public class PostJob
public string? WorkerIp { get; set; }
public DateTime? CompletedDate { get; set; }
public string? Error { get; set; }
public int RetryCount { get; set; }
}

public class CheckPostJobs : IGet, IReturn<CheckPostJobsResponse>
Expand Down

0 comments on commit 4ce37bf

Please sign in to comment.