0

Are the code and comments below from 1 - 7 all correct?

//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();
Pingpong
  • 7,681
  • 21
  • 83
  • 209
  • It looks good to me. I would prefer to wrap the `o.Decorate(...)` and `o.Register(..)` operations in their own extension methods though. If you sign up to [Rebus FM's mailing list](https://rebus.us19.list-manage.com/subscribe?u=7dbeb24095669fc5d85a6e484&id=17cd697097) then you can get weekly Rebus tips, e.g. on how to prettify your configuration – mookid8000 May 30 '19 at 10:49
  • I already subscribed. Can you please check all 7 lines on the OP again? Some of them are related to publisher only, or subscriber only, or both pub and sub. – Pingpong May 30 '19 at 13:27
  • (1) affects both publisher and subscriber, because it configures how `SomeType` in `await bus.Subscribe()` and `await bus.Publish(new SomeType(..))` should be mapped to a topic name – all the others are only relevant for bus instances capable of RECEIVING messages, therefore only for your subscriber – mookid8000 May 31 '19 at 11:13
  • (7) It is not used for both publisher and subscriber on my testing, and It works. Should I keep removing (7) for both of them? – Pingpong May 31 '19 at 11:58
  • Remove (7) – it's not needed with Azure Service Bus, because it has built-in topic-based publish/subscribe – mookid8000 May 31 '19 at 13:43

0 Answers0