Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
namespace AppCoreNet.EventStore
{
/// <summary>
/// An event which is emitted before the transaction processing the event queue is committed.
/// This allows listeners to ensure any buffered work is completed before the transaction is committed.
/// </summary>
[EventType(nameof(EventTransactionCommittingEvent))]
public class EventTransactionCommittingEvent
{
}
}
24 changes: 24 additions & 0 deletions src/AppCoreNet.EventStore/Subscriptions/SubscriptionService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,30 @@ await listener.HandleAsync(watchResult.SubscriptionId, @event, cancellationToken
}
}

try
{
await listener
.HandleAsync(
watchResult.SubscriptionId,
new EventEnvelope(new EventTransactionCommittingEvent()),
cancellationToken)
.ConfigureAwait(false);
}
catch (Exception ex)
{
_logger.LogError(ex, "Error completing event transaction. This action will be retried.");

if (transaction != null)
{
await transaction.RollbackAsync()
.ConfigureAwait(false);
await transaction.DisposeAsync()
.ConfigureAwait(false);
}

continue;
}

await subscriptionStore.UpdateAsync(watchResult.SubscriptionId, lastPosition, cancellationToken)
.ConfigureAwait(false);

Expand Down