通过Rebus在Publisher和Subscriber上都正确的代码和设置

时间:2019-05-29 16:00:38

标签: rebus rebus-azureservicebus

下面1至7的代码和注释正确吗?

//7  below is not needed for both publisher and subscriber    
// .Routing(r => r.TypeBased().MapAssemblyOf<string>(Consts.Publisher))  

Subscriber1

 Configure.With(activator)
                .Logging(l => l.ColoredConsole(minLevel: LogLevel.Warn))
                 .Transport(t => t.UseAzureServiceBus(Consts.ServiceBusConnectionString, Consts.Subscriber1))
                //7  below is not needed for both publisher and subscriber
                // .Routing(r => r.TypeBased().MapAssemblyOf<string>(Consts.Publisher))   
                .Options(o =>
                {
                    //1 can be used for both publisher and subscriber
                    o.Register<ITopicNameConvention>(c => new SimpleTopicNameConvention());

                    //2 only used by consumer
                    o.Decorate<IErrorHandler>(c => new MyErrorHandler(c.Get<IErrorHandler>()));

                    //3 only used by consumer
                    o.SimpleRetryStrategy(maxDeliveryAttempts: 2,
                        errorQueueAddress: "poison");

                    //4 only used by consumer
                    o.SetNumberOfWorkers(5);
                    o.SetMaxParallelism(30);

                    //5 only used by consumer
                    o.SetBackoffTimes(
                        TimeSpan.FromMilliseconds(100),
                        TimeSpan.FromMilliseconds(200),
                        TimeSpan.FromSeconds(1));

                    //6 only used by consumer
                    o.Register<IBackoffStrategy>(c =>
                    {
                        var strategy = new MyBackoffStrategy();
                        return strategy;
                    });

                }).Start();

0 个答案:

没有答案