Skip to content

EasyAbp/Abp.EventBus.CAP

master
Switch branches/tags
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.

Abp.EventBus.CAP

ABP version CAP version NuGet NuGet Download Discord online GitHub stars

ABP vNext framework CAP EventBus module.

Installation

  1. Install the following NuGet packages. (see how)

    • EasyAbp.Abp.EventBus.CAP
    • EasyAbp.Abp.EventBus.Dashboard (if you need the CAP dashboard)
    • EasyAbp.Abp.EventBus.EntityFrameworkCore (if you need CAP transactional outbox)
    • EasyAbp.Abp.EventBus.MongoDB (coming soon...)
    • DotNetCore.CAP.SqlServer (or other DB providers if you are using EF Core)
    • DotNetCore.CAP.MongoDB (if you are using MongoDB)
    • DotNetCore.CAP.RabbitMQ (or other MQ providers)
  2. Add DependsOn(typeof(AbpEventBusCapXxxModule)) attribute to configure the module dependencies. (see how)

  3. Configure the CAP.

    public override void ConfigureServices(ServiceConfigurationContext context)
    {
        var configuration = context.Services.GetConfiguration();
        context.AddCapEventBus(capOptions =>
        {
            // If you are using EF, you need to add:
            options.SetCapDbConnectionString(configuration["ConnectionStrings:Default"]);
            options.UseEntityFramework<MyDbContext>();
    
            // CAP has multiple MQ implementations, e.g. RabbitMQ:
            options.UseRabbitMQ("localhost");
            
            // We provide permission named "CapDashboard.Manage" for authorization.
            options.UseAbpDashboard();
        });
    }

Usage

See the ABP distributed event bus document.

How Do We Integrate CAP?

After ABP 5.0 released, the distributed event bus was redesigned. See: abpframework/abp#6126

// ABP 5.0
Task PublishAsync<TEvent>(TEvent eventData, bool onUnitOfWorkComplete = true, bool useOutbox = true);

// ABP 4.0
Task PublishAsync<TEvent>(TEvent eventData);

Before ABP 5.0, when you invoke PublishAsync, the bus will push the event to MQ at once.

As you can see, after ABP 5.0, events are sent using outbox on UOW complete by default. CAP has a built-in transactional outbox, so we can implement it easily.

If you install the EasyAbp.Abp.EventBus.EntityFrameworkCore module, events are published with CAP's transactional outbox. Otherwise, they are published on UOW completed. See the CapDistributedEventBus for more information.

But there are also some problems with CAP in ABP. In short, an ABP app could have more than one DB connection string, but CAP can only have one, this cannot be solved at present. So if there is not any DB connection string of the current UOW is equal to CAP's, events will be published after the UOW is completed.

Now we have a better solution: https://github.com/EasyAbp/Abp.EventBus.Boxes.Dtm

About

This is a repository integrated CAP with ABP EventBus

Topics

Resources

License

Stars

Watchers

Forks

Contributors 4

  •  
  •  
  •  
  •  

Languages