コード例 #1
0
        public static void AddRabbitMq(this IServiceCollection services, IConfiguration configuration, string configSectionKey)
        {
            var retry = Policy
                        .Handle <Exception>()
                        .WaitAndRetryForever(retryAttempt => TimeSpan.FromMilliseconds(30));

            var options = new RabbitMqOptions();

            configuration.GetSection(configSectionKey).Bind(options);

            services.AddSingleton(context => options);

            retry.Execute(() =>
            {
                var client = RawRabbitFactory.CreateSingleton(new RawRabbitOptions
                {
                    ClientConfiguration = options
                });

                services.AddSingleton <IBusClient>(_ => client);
                services.AddTransient <IBusPublisher, BusPublisher>();
            });
        }
コード例 #2
0
ファイル: BusPublisher.cs プロジェクト: mghanii/ACC
 public BusPublisher(IBusClient client, RabbitMqOptions options)
 {
     _busClient       = client;
     _rabbitMqOptions = options;
 }