public RabbitMQListener(
     IBusClient busClient,
     IOptions <RabbitMQOptions> options,
     IServiceScopeFactory serviceFactory)
 {
     _busClient      = busClient;
     _serviceFactory = serviceFactory;
     _options        = options.Value;
 }
예제 #2
0
        public static IServiceCollection AddRabbitMQ(this IServiceCollection services, IConfiguration Configuration)
        {
            var options = new RabbitMQOptions();

            Configuration.GetSection(nameof(MessageBrokersOptions)).Bind(options);
            services.Configure <RabbitMQOptions>(Configuration.GetSection(nameof(MessageBrokersOptions)));

            services.AddRawRabbit(new RawRabbitOptions
            {
                ClientConfiguration = options
            });

            services.AddSingleton <IEventListener, RabbitMQListener>();

            return(services);
        }