-
-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Fixed auto-retry as per this forum post: https://discuss.hangfire.io/t/recurring-jobs-do-not-automatically-get-retried-after-application-crash-net-core-service/9160 * MongoDB can't handle documents greater than 16MB * Treat messages from one id as a group * Kill failing messages over 4 days old * Make outbox truly generic, handling multiple queues * Ensure globally ordered outbox messages * Add "MoveAsync" to SharedStorage * Refactor saving pretranslations file
- Loading branch information
1 parent
1011777
commit 6362191
Showing
37 changed files
with
1,142 additions
and
137 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 8 additions & 0 deletions
8
src/SIL.Machine.AspNetCore/Configuration/MessageOutboxOptions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
namespace SIL.Machine.AspNetCore.Configuration; | ||
|
||
public class MessageOutboxOptions | ||
{ | ||
public const string Key = "MessageOutbox"; | ||
|
||
public int MessageExpirationInHours { get; set; } = 48; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
namespace SIL.Machine.AspNetCore.Models; | ||
|
||
public record Outbox : IEntity | ||
{ | ||
public string Id { get; set; } = ""; | ||
|
||
public int Revision { get; set; } | ||
|
||
public string Name { get; set; } = null!; | ||
public int CurrentIndex { get; set; } | ||
|
||
public static async Task<Outbox> GetOutboxNextIndexAsync( | ||
IRepository<Outbox> indexRepository, | ||
string outboxName, | ||
CancellationToken cancellationToken | ||
) | ||
{ | ||
Outbox outbox = ( | ||
await indexRepository.UpdateAsync( | ||
i => i.Name == outboxName, | ||
i => i.Inc(b => b.CurrentIndex, 1), | ||
upsert: true, | ||
cancellationToken: cancellationToken | ||
) | ||
)!; | ||
return outbox; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
namespace SIL.Machine.AspNetCore.Models; | ||
|
||
public record OutboxMessage : IEntity | ||
{ | ||
public string Id { get; set; } = ""; | ||
public int Revision { get; set; } = 1; | ||
public required int Index { get; set; } | ||
public required string OutboxName { get; set; } | ||
public required string Method { get; set; } | ||
public required string GroupId { get; set; } | ||
public required string? RequestContent { get; set; } | ||
public DateTimeOffset Created { get; set; } = DateTimeOffset.UtcNow; | ||
public int Attempts { get; set; } = 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
src/SIL.Machine.AspNetCore/Services/IMessageOutboxService.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
namespace SIL.Machine.AspNetCore.Services; | ||
|
||
public interface IMessageOutboxService | ||
{ | ||
public Task<string> EnqueueMessageAsync<T>( | ||
T method, | ||
string groupId, | ||
string? requestContent = null, | ||
string? requestContentPath = null, | ||
CancellationToken cancellationToken = default | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
namespace SIL.Machine.AspNetCore.Services; | ||
|
||
public interface IOutboxMessageHandler | ||
{ | ||
public string Name { get; } | ||
|
||
public Task SendMessageAsync(OutboxMessage message, CancellationToken cancellationToken = default); | ||
public Task CleanupMessageAsync(OutboxMessage message, CancellationToken cancellationToken = default); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.