コード例 #1
0
 public static ContainerBuilder AddEventBus(this ContainerBuilder builder)
 {
     builder.RegisterRebus((configurer, context) => configurer
                           .Logging(l => l.Serilog())
                           .Transport(t =>
     {
         var connections = context.Resolve <Connections>();
         t.UseRabbitMq(connections.RabbitConnectionString, connections.Queue);
     })
                           .Options(o => {
         o.Decorate <IPipeline>(ctx =>
         {
             var step     = new LoggerStep();
             var pipeline = ctx.Get <IPipeline>();
             return(new PipelineStepInjector(pipeline).OnReceive(step, PipelineRelativePosition.After, typeof(ActivateHandlersStep)));
         });
         o.Decorate <IPipeline>(ctx =>
         {
             var step     = new HeadersIncomingStep();
             var pipeline = ctx.Get <IPipeline>();
             return(new PipelineStepInjector(pipeline).OnReceive(step, PipelineRelativePosition.Before, typeof(LoggerStep)));
         });
         o.LogPipeline(true);
         o.SetNumberOfWorkers(1);
         o.SetMaxParallelism(30);
     }));
     builder.RegisterType <EventBus>().AsImplementedInterfaces();
     return(builder);
 }
コード例 #2
0
        protected override void Load(ContainerBuilder builder)
        {
            var types =
                GetType().Assembly.GetTypes()
                .Where(type => typeof(IHandleMessages).IsAssignableFrom(type))
                .ToArray();

            builder.RegisterTypes(types)
            .AsImplementedInterfaces()
            .InstancePerLifetimeScope();

            builder.RegisterRebus((configurer, context) => configurer
                                  .Logging(l => l.Serilog())
                                  .Transport(t => t.UseRabbitMq("amqp://docker", "testappqueue"))
                                  .Options(o => {
                o.Decorate <IPipeline>(ctx =>
                {
                    var step     = new LoggerStep();
                    var pipeline = ctx.Get <IPipeline>();
                    return(new PipelineStepInjector(pipeline).OnReceive(step, PipelineRelativePosition.After, typeof(ActivateHandlersStep)));
                });
                o.Decorate <IPipeline>(ctx =>
                {
                    var step     = new HeadersIncomingStep();
                    var pipeline = ctx.Get <IPipeline>();
                    return(new PipelineStepInjector(pipeline).OnReceive(step, PipelineRelativePosition.Before, typeof(LoggerStep)));
                });
                o.LogPipeline(true);
                o.SetNumberOfWorkers(1);
                o.SetMaxParallelism(30);
            }));
            builder.RegisterType <EventBus>().AsImplementedInterfaces();
            builder.RegisterType <EventSubscriber>().AsImplementedInterfaces();
        }