Exemple #1
0
        private static void ConfigureServices(HostBuilderContext context, IServiceCollection services)
        {
            var configuration = context.Configuration;

            //Buss

            var rabbitMqUri = configuration.GetSection($"{nameof(RabbitMqConfig)}:{nameof(RabbitMqConfig.Uri)}")
                              .Value;
            var userName = configuration.GetSection($"{nameof(RabbitMqConfig)}:{nameof(RabbitMqAuthConfig.UserName)}")
                           .Value;
            var password = configuration.GetSection($"{nameof(RabbitMqConfig)}:{nameof(RabbitMqAuthConfig.Password)}")
                           .Value;
            var config = (rabbitMqUri, userName, password);

            services.AddMassTransit(configurator =>
            {
                configurator.AddBus(provider => Configurator.ConfigureBus(config, (factoryConfigurator, host) =>
                {
                    var submitQueue = configuration
                                      .GetSection($"{nameof(RabbitMqConfig)}:{nameof(RabbitMqConfig.MessageQueue)}").Value;
                    factoryConfigurator.ReceiveEndpoint(host, submitQueue, e =>
                    {
                        e.UseRetry(Retry.Except <ArgumentException>().Intervals(400));
                        e.UseRateLimit(100, TimeSpan.FromSeconds(1));
                        e.Consumer <SubmitMessageHandler>();
                    });
                }));
            });

            services.AddHostedService <MassTransitHostedService>();
        }
        protected override void ConfigureInputQueueEndpoint(IInMemoryReceiveEndpointConfigurator configurator)
        {
            _machine    = new TestStateMachine();
            _repository = new InMemorySagaRepository <Instance>();

            configurator.UseRetry(Retry.Except <NotSupportedException>().Immediate(2));

            configurator.StateMachineSaga(_machine, _repository);
        }
Exemple #3
0
        public void Should_not_include_the_excluded()
        {
            var tracker = new Tracker(3);

            IRetryPolicy retryPolicy = Retry.Except <InvalidOperationException>().Immediate(5);

            Task task = ComposerFactory.Compose(composer => composer.Retry(retryPolicy, x => x.Execute(tracker.FaultingMethod)));

            Assert.Throws <InvalidOperationException>(async() => await task);

            Assert.AreEqual(1, tracker.CallCount);
        }