From 6b14fe73f3a9e82f0e13bb800bd174a4cf105ea9 Mon Sep 17 00:00:00 2001 From: maliming Date: Mon, 15 Sep 2025 16:25:13 +0800 Subject: [PATCH] Optimize event retry time evaluation in inbox classes --- .../DistributedEvents/DbContextEventInbox.cs | 3 ++- .../Abp/MongoDB/DistributedEvents/MongoDbContextEventInbox.cs | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/framework/src/Volo.Abp.EntityFrameworkCore/Volo/Abp/EntityFrameworkCore/DistributedEvents/DbContextEventInbox.cs b/framework/src/Volo.Abp.EntityFrameworkCore/Volo/Abp/EntityFrameworkCore/DistributedEvents/DbContextEventInbox.cs index 2e148a97c6..82fd3b5d2e 100644 --- a/framework/src/Volo.Abp.EntityFrameworkCore/Volo/Abp/EntityFrameworkCore/DistributedEvents/DbContextEventInbox.cs +++ b/framework/src/Volo.Abp.EntityFrameworkCore/Volo/Abp/EntityFrameworkCore/DistributedEvents/DbContextEventInbox.cs @@ -47,11 +47,12 @@ public class DbContextEventInbox : IDbContextEventInbox transformedFilter = InboxOutboxFilterExpressionTransformer.Transform(filter)!; } + var now = Clock.Now; var outgoingEventRecords = await dbContext .IncomingEvents .AsNoTracking() .Where(x => x.Status == IncomingEventStatus.Pending) - .Where(x => x.NextRetryTime == null || x.NextRetryTime <= Clock.Now) + .Where(x => x.NextRetryTime == null || x.NextRetryTime <= now) .WhereIf(transformedFilter != null, transformedFilter!) .OrderBy(x => x.CreationTime) .Take(maxCount) diff --git a/framework/src/Volo.Abp.MongoDB/Volo/Abp/MongoDB/DistributedEvents/MongoDbContextEventInbox.cs b/framework/src/Volo.Abp.MongoDB/Volo/Abp/MongoDB/DistributedEvents/MongoDbContextEventInbox.cs index 427c794542..8baeb82f3a 100644 --- a/framework/src/Volo.Abp.MongoDB/Volo/Abp/MongoDB/DistributedEvents/MongoDbContextEventInbox.cs +++ b/framework/src/Volo.Abp.MongoDB/Volo/Abp/MongoDB/DistributedEvents/MongoDbContextEventInbox.cs @@ -61,11 +61,12 @@ public class MongoDbContextEventInbox : IMongoDbContextEventInb transformedFilter = InboxOutboxFilterExpressionTransformer.Transform(filter)!; } + var now = Clock.Now; var outgoingEventRecords = await dbContext .IncomingEvents .AsQueryable() .Where(x => x.Status == IncomingEventStatus.Pending) - .Where(x => x.NextRetryTime == null || x.NextRetryTime <= Clock.Now) + .Where(x => x.NextRetryTime == null || x.NextRetryTime <= now) .WhereIf(transformedFilter != null, transformedFilter!) .OrderBy(x => x.CreationTime) .Take(maxCount)