Open Closed

Distributed Event Handler in Console App - Handler being triggered multiple times #2170


User avatar
0
pszatkowski created

Hello, We're using the distributed event bus using Rebus with an Azure Service Bus store. We have a web application and console application which need to be loosely coupled. We're successfully emitting an EntityCreatedEto<SalesOrderEto> event from the web app which gets sent exactly once to the Azure Service Bus topic but for some reason, our handler in the console app gets triggered three times.

In the console app we see the subscription get registered:

[INF] Rebus.AzureServiceBus.AzureServiceBusTransport (.NET ThreadPool Worker): Subscription "HadesConsoleClient" for topic "Volo.Abp.Ddd.Domain/Volo.Abp.Domain.Entities.Events.Distributed.EntityCreatedEto_1__Hurst.TFCC.Hades.SalesOrder.SalesOrderEto__Hurst.TFCC.Hades.SalesOrder.Domain.Shared__Version_0.1.0.0__Culture_neutral__PublicKeyToken_null__" successfully registered

The handler class is not doing anything except logging at the moment:

using System.Threading.Tasks;
using Hurst.TFCC.Hades.SalesOrder;
using Microsoft.Extensions.Logging;
using Volo.Abp.DependencyInjection;
using Volo.Abp.Domain.Entities.Events.Distributed;
using Volo.Abp.EventBus.Distributed;

namespace Hurst.TFCC.Hades.StevensWorker;

public class SalesOrderReceiverHandler: ITransientDependency, IDistributedEventHandler<EntityCreatedEto<SalesOrderEto>>
{
    private readonly ILogger<SalesOrderReceiverHandler> _logger;
    
    public SalesOrderReceiverHandler(ILogger<SalesOrderReceiverHandler> logger)
    {
        _logger = logger;
    }

    public async Task HandleEventAsync(EntityCreatedEto<SalesOrderEto> eventData)
    {
        _logger.LogInformation("Received Sales Order ETO for order number: {OrderNumber}",
            eventData.Entity.OrderNumber);
    }
}

However, it triggers three times:

[12:02:32 INF] Received Sales Order ETO for order number: 1239
[12:02:32 INF] Received Sales Order ETO for order number: 1239
[12:02:32 INF] Received Sales Order ETO for order number: 1239

The Rebus debug messages note it has dispatched to 3 handlers:

[DBG] Rebus.Pipeline.Receive.DispatchIncomingMessageStep (.NET ThreadPool Worker): Dispatching "Volo.Abp.Domain.Entities.Events.Distributed.EntityCreatedEto`1[[Hurst.TFCC.Hades.SalesOrder.SalesOrderEto, Hurst.TFCC.Hades.SalesOrder.Domain.Shared]], Volo.Abp.Ddd.Domain" "4b6802d0-af01-42b0-87c2-75a8c58368b0" to 3 handlers took 14 ms

Any ideas why this is triggering three times? This project is using ABP v5.0.0-rc.1.


1 Answer(s)
  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi pszatkowski

    Can you share a simplest project to reproduce the problem.

Made with ❤️ on ABP v9.1.0-preview. Updated on November 11, 2024, 11:11