コード例 #1
0
        public static void AddRabbitMq(this IServiceCollection services, IConfiguration configuration)
        {
            var options = new RabbitMqOptions();
            var section = configuration.GetSection("rabbitmq");

            section.Bind(options);
            var client = RawRabbitFactory.CreateSingleton(new RawRabbitOptions {
                ClientConfiguration = options
            });

            services.AddSingleton <IBusClient>(_ => client);
        }
コード例 #2
0
ファイル: Extensions.cs プロジェクト: Allesad/Actio-Demo
        public static void AddRabbitMq(this IServiceCollection services, IConfiguration configuration)
        {
            var options = new RabbitMqOptions();
            var section = configuration.GetSection("RabbitMq");

            section.Bind(options);

            Console.WriteLine($"Setup RabbitMq on {options.Hostnames[0]}:{options.Port}");

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

            services.AddSingleton <IBusClient>(client);
        }
コード例 #3
0
        public static void AddRabbitMq(this IServiceCollection services, IConfiguration configuration)
        {
            if (configuration == null)
            {
                throw new ArgumentNullException(nameof(configuration));
            }

            var options = new RabbitMqOptions();
            var section = configuration.GetSection("RabbitMq");

            section.Bind(options);

            using (var client = RawRabbitFactory.CreateSingleton(new RawRabbitOptions
            {
                ClientConfiguration = options,
                DependencyInjection = ioc => ioc.AddSingleton(LoggingFactory.ApplicationLogger),
                Plugins = p => p
                          .UseStateMachine()
                          .UseGlobalExecutionId()
            }))
            {
                services.AddSingleton <IBusClient>(_ => client);
            }
        }