public Task StartAsync(CancellationToken cancellationToken) { try { _manager = new MQServcieManager(); foreach (var dbMapping in _rabitMqOption.DbTables) { _manager.AddService(new ConsumeService(_rabitMqOption, dbMapping, _dbTypeMapper) { OnAction = OnActionOutput }); } _manager.OnAction = OnActionOutput; _manager.Start(); AppDomain.CurrentDomain.ProcessExit += CurrentDomainOnProcessExit; _logger.LogInformation("rabit consume client start succ..."); } catch (Exception ex) { _logger.LogError(ex, "rabit consume client start error..."); } return(Task.CompletedTask); }
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(); }