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);
        }
Beispiel #2
0
        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);
        }
Beispiel #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);
            }
        }