Browse Source

Merge pull request #24550 from abpframework/DistributedEventBusBase_AddToInbox

Add logic to set addToInbox to true if messageId exists in event inbox
pull/24573/head
Engincan VESKE 4 weeks ago
committed by GitHub
parent
commit
4e6a32d042
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 9
      framework/src/Volo.Abp.EventBus/Volo/Abp/EventBus/Distributed/DistributedEventBusBase.cs

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

@ -43,7 +43,7 @@ public abstract class DistributedEventBusBase : EventBusBase, IDistributedEventB
CorrelationIdProvider = correlationIdProvider;
}
public IDisposable Subscribe<TEvent>(IDistributedEventHandler<TEvent> handler) where TEvent : class
public virtual IDisposable Subscribe<TEvent>(IDistributedEventHandler<TEvent> handler) where TEvent : class
{
return Subscribe(typeof(TEvent), handler);
}
@ -53,7 +53,7 @@ public abstract class DistributedEventBusBase : EventBusBase, IDistributedEventB
return PublishAsync(eventType, eventData, onUnitOfWorkComplete, useOutbox: true);
}
public Task PublishAsync<TEvent>(
public virtual Task PublishAsync<TEvent>(
TEvent eventData,
bool onUnitOfWorkComplete = true,
bool useOutbox = true)
@ -154,7 +154,7 @@ public abstract class DistributedEventBusBase : EventBusBase, IDistributedEventB
return Task.CompletedTask;
}
protected async Task<bool> AddToInboxAsync(
protected virtual async Task<bool> AddToInboxAsync(
string? messageId,
string eventName,
Type eventType,
@ -181,6 +181,9 @@ public abstract class DistributedEventBusBase : EventBusBase, IDistributedEventB
{
if (await eventInbox.ExistsByMessageIdAsync(messageId!))
{
// Message already exists in the inbox, no need to add again.
// This can happen in case of retries from the sender side.
addToInbox = true;
continue;
}
}

Loading…
Cancel
Save