Skip to content

目前dotnetcore.cap7,8 消费者过滤器只能单个并不支持中间件的,这里提供一种支持中间件的实现方法...

License

Notifications You must be signed in to change notification settings

vl00/Common.CAP

Repository files navigation

Common.CAP

NuGet

目前dotnetcore.cap7,8 消费者过滤器只能单个并不支持中间件的,这里提供一种支持中间件的实现方法...

  1. 先引用包 Common.CAP 到你项目
  2. 编写中间件和全局注册
    [AttributeUsage(AttributeTargets.Class | AttributeTargets.Method)]
    public class Middler1 : CapSubscribeMiddlerAttribute
    {
        public override Task ExecuteAsync(CapSubscribeExecutingContext context, CapSubscribeMiddlerExecuteFunc next)
        {
            // your codes ...
        }
    }
    
    // 使用:
    //[Middler1(Order = 100)]
    public class Class1 : BaseExecCap, ICapSubscribe
    {
        [Middler1]
        public Task Method() { ... }
    }
    
    // 全局注册:
    services.AddCap(...);
    services.AddSupportCapSubscribeFilterToMiddlers((_, f) => 
    {
        //f.AddMiddler(new Middler1(), -1000); // 可全局注册
        // ...
    });
  3. cd Sample1 && dotnet build
  4. 运行本库 ./rg.cap.bat 生成
  5. cd Sample1 && dotnet run

See more: Common.CAP 实现分布式saga(事务)流程

About

目前dotnetcore.cap7,8 消费者过滤器只能单个并不支持中间件的,这里提供一种支持中间件的实现方法...

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published