0
Payoff created
Version 6.x introduce Publish with option to specify MessageId, but we need to read it and other attributes to avoid potential duplicate handling. I've not found any easy way to read messageId and other parameters like rbs2-senttime, rbs2-corr-id, ... from handler am I missing something?
I want to create something on top like: https://www.milanjovanovic.tech/blog/idempotent-consumer-handling-duplicate-messages Can I have entry point to add this to out solution?
tnx mik
1 Answer(s)
-
0
Hi,
You can try to custom the
RebusDistributedEventBus
.For example:
[Dependency(ReplaceServices = true)] [ExposeServices(typeof(IDistributedEventBus), typeof(RebusDistributedEventBus))] public class MyRebusDistributedEventBus : RebusDistributedEventBus { public MyRebusDistributedEventBus(IServiceScopeFactory serviceScopeFactory, ICurrentTenant currentTenant, IUnitOfWorkManager unitOfWorkManager, IBus rebus, IOptions<AbpDistributedEventBusOptions> abpDistributedEventBusOptions, IOptions<AbpRebusEventBusOptions> abpEventBusRebusOptions, IRebusSerializer serializer, IGuidGenerator guidGenerator, IClock clock, IEventHandlerInvoker eventHandlerInvoker) : base(serviceScopeFactory, currentTenant, unitOfWorkManager, rebus, abpDistributedEventBusOptions, abpEventBusRebusOptions, serializer, guidGenerator, clock, eventHandlerInvoker) { } public async override Task TriggerHandlersAsync(Type eventType, object eventData) { var messageId = MessageContext.Current.TransportMessage.GetMessageId(); var sentTime = MessageContext.Current.Headers["rbs2-senttime"]; if (....) { return; } await base.TriggerHandlersAsync(eventType, eventData); } }