Browse Source

Add logic to set addToInbox to true if messageId exists in event inbox

pull/24550/head
maliming 1 month ago
parent
commit
5d07af6001
No known key found for this signature in database GPG Key ID: A646B9CB645ECEA4
  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