コード例 #1
0
        public static IBusControl Create(MassTransitOptions options, Action <IRabbitMqBusFactoryConfigurator, IRabbitMqHost> registrationAction = null)
        {
            return(Bus.Factory.CreateUsingRabbitMq(cfg =>
            {
                var host = cfg.Host(options.HostUri, hst =>
                {
                    hst.Username(options.Username);
                    hst.Password(options.Password);
                });

                if (options.RetryPolicy != null)
                {
                    cfg.UseRetry(options.RetryPolicy);
                }

                if (options.TripThreshold != null && options.ActiveThreshold != null && options.ResetInterval != null)
                {
                    cfg.UseCircuitBreaker(cb =>
                    {
                        cb.TripThreshold = options.TripThreshold.Value;
                        cb.ActiveThreshold = options.ActiveThreshold.Value;
                        cb.ResetInterval = TimeSpan.FromMinutes(options.ResetInterval.Value);
                    });
                }

                if (options.RateLimit != null && options.RateLimiterInterval != null)
                {
                    cfg.UseRateLimit(options.RateLimit.Value, TimeSpan.FromSeconds(options.RateLimiterInterval.Value));
                }

                registrationAction?.Invoke(cfg, host);
            }));
        }
コード例 #2
0
 public MassTransitEventBus(MassTransitOptions options)
 {
     _options = options;
 }