public static void UseRabbitListener(this IApplicationBuilder app)
        {
            Listener = app.ApplicationServices.GetService <EventBusRabbitMQConsumer>();
            var lifeCycle = app.ApplicationServices.GetService <IHostApplicationLifetime>();

            lifeCycle.ApplicationStarted.Register(OnStarted);
            lifeCycle.ApplicationStopping.Register(OnStopping);
        }
        public static IApplicationBuilder UseRabbitMQListner(this IApplicationBuilder app)
        {
            Listner = app.ApplicationServices.GetService <EventBusRabbitMQConsumer>();
            var life = app.ApplicationServices.GetService <IHostApplicationLifetime>();

            life.ApplicationStarted.Register(OnStarted);
            life.ApplicationStopped.Register(OnStopping);
            return(app);
        }
        public static IApplicationBuilder UseRabbitListener(this IApplicationBuilder app, IServiceProvider serviceProvider)
        {
            Listener = serviceProvider.GetRequiredService <EventBusRabbitMQConsumer>();//app.ApplicationServices.GetService<EventBusRabbitMQConsumer>();
            var life = app.ApplicationServices.GetService <IHostApplicationLifetime>();

            life.ApplicationStarted.Register(OnStarted);
            life.ApplicationStopping.Register(OnStopping);
            return(app);
        }
Пример #4
0
        public static IApplicationBuilder UseRabbitListener(this IApplicationBuilder app)
        {                                                                               //así se declara un extention method, el método debería estar dentro de esta interfaz
            Listener = app.ApplicationServices.GetService <EventBusRabbitMQConsumer>(); //parece que así obtenes algo por inyección de dependencia
            var life = app.ApplicationServices.GetService <IHostApplicationLifetime>();

            life.ApplicationStarted.Register(OnStarted);
            life.ApplicationStopping.Register(OnStopping);

            return(app);
        }
Пример #5
0
        public static IApplicationBuilder UseRabbitMQListener(this IApplicationBuilder applicationBuilder)
        {
            RabbitMqConsumer = applicationBuilder.ApplicationServices.GetService <EventBusRabbitMQConsumer>();
            var lifetime = applicationBuilder.ApplicationServices.GetService <IHostApplicationLifetime>();

            // This way I can gain access to asp.net app lifetime
            lifetime.ApplicationStarted.Register(OnStarted);
            lifetime.ApplicationStopping.Register(OnStopping);
            return(applicationBuilder);
        }
Пример #6
0
        public static IApplicationBuilder UseRabbitListener(this IApplicationBuilder app)
        {
            //get the predefined inject consumer from the services.
            Listener = app.ApplicationServices.GetService <EventBusRabbitMQConsumer>();
            var life = app.ApplicationServices.GetService <IHostApplicationLifetime>();

            life.ApplicationStarted.Register(OnStarted);
            life.ApplicationStopped.Register(OnStopped);

            return(app);
        }
Пример #7
0
        public static IApplicationBuilder UseRabbitMQListener(this IApplicationBuilder app)
        {
            //servis örneğinin alınması
            //

            /*
             * Allows consumers to be notified of application lifetime events.
             */
            Listener = app.ApplicationServices.GetService <EventBusRabbitMQConsumer>();
            var life = app.ApplicationServices.GetService <IHostApplicationLifetime>();

            life.ApplicationStarted.Register(OnStarted);
            life.ApplicationStopping.Register(OnStopping);
            return(app);
        }