Open Closed

Azure service bus incomplete documentation and sample code not working. #2188


User avatar
0
imranStem created

I have downloaded the latest source code from the Github repository and I successfully build the ABP framework and Azure Event bus sample code. I configured the azure connection string, topic name, and subscription. When I run the project, it throws the stack overflow exception. I debug the code and found the following issues.

public async Task PublishAsync(
        Type eventType,
        object eventData,
        bool onUnitOfWorkComplete = true,
        bool useOutbox = true)
    {
        if (onUnitOfWorkComplete && UnitOfWorkManager.Current != null)
        {
            AddToUnitOfWork(
                UnitOfWorkManager.Current,
                new UnitOfWorkEventRecord(eventType, eventData, EventOrderGenerator.GetNext(), useOutbox)
            );
            return;
        }
        if (useOutbox)
        {
            if (await AddToOutboxAsync(eventType, eventData))
            {
                return;
            }
        }
        await PublishToEventBusAsync(eventType, eventData);
    }`

In the above code, the value of UnitOfWorkManager.Current is null so it jumps to the second condition, and executes the AddToOutboxAsync method.

`private async Task<bool> AddToOutboxAsync(Type eventType, object eventData)
    {
        var unitOfWork = UnitOfWorkManager.Current;
        if (unitOfWork == null)
        {
            return false;
        }
        foreach (var outboxConfig in AbpDistributedEventBusOptions.Outboxes.Values)
        {
            if (outboxConfig.Selector == null || outboxConfig.Selector(eventType))
            {
                var eventOutbox = (IEventOutbox)unitOfWork.ServiceProvider.GetRequiredService(outboxConfig.ImplementationType);
                var eventName = EventNameAttribute.GetNameOrDefault(eventType);
                await eventOutbox.EnqueueAsync(
                    new OutgoingEventInfo(
                        GuidGenerator.Create(),
                        eventName,
                        Serialize(eventData),
                        Clock.Now
                    )
                );
                return true;
            }
        }
        return false;
    }

Again, in the above method, it checks the unit of work which is null so it returns false and PublishToEventBusAsync is executing and that method again calls the first publish method so the code executing into the loop and throws stack overflow exception.

I also tried to read the documents on azure event bus, the link redirects to 404 page.

Distributed-Event-Bus-Azure-Integration

I successfully integerated the RabbitMq integration in my project but we are planning to migrate into Azure service bus with ABP 5.0 version but it is in preview mode and documentation is not completed yet.

Thanks Imrankhan

  • ABP Framework version: v5.0.0
  • UI type: Angular
  • DB provider: EF Core
  • Tiered (MVC) or Identity Server Separated (Angular): yes
  • Exception message and stack trace:
  • Steps to reproduce the issue:" Download the sample codes of azure service bus and run the console application.

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

    hi

    You can check the document at:https://github.com/abpframework/abp/blob/rel-5.0/docs/en/Distributed-Event-Bus-Azure-Integration.md

    https://github.com/abpframework/abp/pull/10744

    I configured the azure connection string, topic name, and subscription.

    Can you share these info? liming.ma@volosoft.com

  • User Avatar
    0
    imranStem created

    Hello Liming,

    I sent info in your email.

Made with ❤️ on ABP v8.2.0-preview Updated on March 25, 2024, 15:11