Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Send work item failed progress messages #284

Merged
merged 7 commits into from
Jan 9, 2023
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/Foundatio/Jobs/WorkItemJob/WorkItemJob.cs
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,9 @@ public class WorkItemJob : IQueueJob<WorkItemData>, IHaveLogger {

return JobResult.Success;
} catch (Exception ex) {

await ReportProgressAsync(handler, queueEntry, -1, $"Failed: {ex.Message}").AnyContext();
akshay-zz marked this conversation as resolved.
Show resolved Hide resolved

if (!queueEntry.IsAbandoned && !queueEntry.IsCompleted) {
await queueEntry.AbandonAsync().AnyContext();
return JobResult.FromException(ex, $"Abandoning {queueEntry.Value.Type} work item: {queueEntry.Id}: Error in handler {workItemDataType.Name}");
Expand Down
2 changes: 1 addition & 1 deletion tests/Foundatio.Tests/Jobs/WorkItemJobTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ public class WorkItemJobTests : TestWithLoggingBase {

await job.RunUntilEmptyAsync();
await countdown.WaitAsync(TimeSpan.FromSeconds(2));
Assert.Equal(0, countdown.CurrentCount);
akshay-zz marked this conversation as resolved.
Show resolved Hide resolved
Assert.Equal(-1, countdown.CurrentCount);
}
}

Expand Down