Exemple #1
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory factory, IApplicationLifetime lifeTime)
        {
            serviceManager = new MQServcieManager(this.Configuration, factory.CreateLogger <MQServcieManager>());
            lifeTime.ApplicationStarted.Register(() => { serviceManager.Start(); });
            lifeTime.ApplicationStopping.Register(() => { serviceManager.Stop(); });

            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }
            else
            {
                app.UseExceptionHandler("/Home/Error");
            }

            app.UseStaticFiles();
            app.UseCookiePolicy();

            app.UseMvc(routes =>
            {
                routes.MapRoute(
                    name: "default",
                    template: "{controller=Home}/{action=Index}/{id?}");
            });
        }
 private static void UseRabbitMQ(IConfiguration configuration)
 {
     mqManager = new MQServcieManager(logWriter, filterService, configuration, logger);
     lifeTime.ApplicationStarted.Register(() =>
     {
         mqManager.Start();
     });
     lifeTime.ApplicationStopping.Register(() =>
     {
         mqManager.Stop();
     });
 }
Exemple #3
0
 public void Dispose()
 {
     try
     {
         if (isDispose)
         {
             return;
         }
         isDispose = true;
         _manager.Stop();
         _logger.LogInformation("rabit consume client stop succ...");
     }
     catch (Exception ex)
     {
         _logger.LogError(ex, "rabit consume client stop error...");
     }
 }
Exemple #4
0
        static void Test()
        {
            MQConfig config = new MQConfig()
            {
                HostName = "172.16.1.219",
                Password = "******",
                Port     = 5672,
                UserName = "******"
            };

            MQServcieManager manager = new MQServcieManager();

            manager.AddService(new DemoService(config));
            manager.OnAction = OnActionOutput;
            manager.Start();

            Console.WriteLine("服务已启动");
            Console.ReadKey();

            manager.Stop();
            Console.WriteLine("服务已停止,按任意键退出...");
            Console.ReadKey();
        }