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

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

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

            services.AddSingleton <IEventListener, RabbitMQListener>();

            return(services);
        }