diff --git a/src/Persistence/EfCoreTests/end_to_end_efcore_persistence.cs b/src/Persistence/EfCoreTests/end_to_end_efcore_persistence.cs index e98728b51..3ef08a460 100644 --- a/src/Persistence/EfCoreTests/end_to_end_efcore_persistence.cs +++ b/src/Persistence/EfCoreTests/end_to_end_efcore_persistence.cs @@ -99,6 +99,7 @@ public async Task ef_core_middleware_is_marking_the_envelope_as_handled() var persisted = fromStore.Single(x => x.Id == envelope.Id); persisted.Status.ShouldBe(EnvelopeStatus.Handled); + persisted.KeepUntil.HasValue.ShouldBeTrue(); } private async Task loadItem(Guid id) diff --git a/src/Persistence/Wolverine.EntityFrameworkCore/Internals/EfCoreEnvelopeTransaction.cs b/src/Persistence/Wolverine.EntityFrameworkCore/Internals/EfCoreEnvelopeTransaction.cs index 585d3ace1..aa1e23ba2 100644 --- a/src/Persistence/Wolverine.EntityFrameworkCore/Internals/EfCoreEnvelopeTransaction.cs +++ b/src/Persistence/Wolverine.EntityFrameworkCore/Internals/EfCoreEnvelopeTransaction.cs @@ -170,10 +170,13 @@ public async ValueTask CommitAsync(CancellationToken cancellation) // Are we marking an existing envelope as persisted? if (_messaging.Envelope.WasPersistedInInbox) - { + { + var keepUntil = + DateTimeOffset.UtcNow.Add(_messaging.Runtime.Options.Durability.KeepAfterMessageHandling); var cmd = conn.CreateCommand( - $"update {_database.SchemaName}.{DatabaseConstants.IncomingTable} set {DatabaseConstants.Status} = '{EnvelopeStatus.Handled}' where id = @id") - .With("id", _messaging.Envelope.Id); + $"update {_database.SchemaName}.{DatabaseConstants.IncomingTable} set {DatabaseConstants.Status} = '{EnvelopeStatus.Handled}', {DatabaseConstants.KeepUntil} = @keep where id = @id") + .With("id", _messaging.Envelope.Id) + .With("keep", keepUntil); cmd.Transaction = tx; await cmd.ExecuteNonQueryAsync(cancellation); }