Skip to content

Commit 4e6a32d

Browse files
authored
Merge pull request #24550 from abpframework/DistributedEventBusBase_AddToInbox
Add logic to set addToInbox to true if messageId exists in event inbox
2 parents c9d6540 + 5d07af6 commit 4e6a32d

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

framework/src/Volo.Abp.EventBus/Volo/Abp/EventBus/Distributed/DistributedEventBusBase.cs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ protected DistributedEventBusBase(
4343
CorrelationIdProvider = correlationIdProvider;
4444
}
4545

46-
public IDisposable Subscribe<TEvent>(IDistributedEventHandler<TEvent> handler) where TEvent : class
46+
public virtual IDisposable Subscribe<TEvent>(IDistributedEventHandler<TEvent> handler) where TEvent : class
4747
{
4848
return Subscribe(typeof(TEvent), handler);
4949
}
@@ -53,7 +53,7 @@ public override Task PublishAsync(Type eventType, object eventData, bool onUnitO
5353
return PublishAsync(eventType, eventData, onUnitOfWorkComplete, useOutbox: true);
5454
}
5555

56-
public Task PublishAsync<TEvent>(
56+
public virtual Task PublishAsync<TEvent>(
5757
TEvent eventData,
5858
bool onUnitOfWorkComplete = true,
5959
bool useOutbox = true)
@@ -154,7 +154,7 @@ protected virtual Task OnAddToOutboxAsync(string eventName, Type eventType, obje
154154
return Task.CompletedTask;
155155
}
156156

157-
protected async Task<bool> AddToInboxAsync(
157+
protected virtual async Task<bool> AddToInboxAsync(
158158
string? messageId,
159159
string eventName,
160160
Type eventType,
@@ -181,6 +181,9 @@ protected async Task<bool> AddToInboxAsync(
181181
{
182182
if (await eventInbox.ExistsByMessageIdAsync(messageId!))
183183
{
184+
// Message already exists in the inbox, no need to add again.
185+
// This can happen in case of retries from the sender side.
186+
addToInbox = true;
184187
continue;
185188
}
186189
}

0 commit comments

Comments
 (0)