Exemplo n.º 1
0
 public Task StartAsync(CancellationToken cancellationToken)
 {
     try
     {
         _canalConnector = CanalConnectors.NewSingleConnector(_canalOption.Host, _canalOption.Port, _canalOption.Destination, _canalOption.MysqlName, _canalOption.MysqlPwd);
         _canalConnector.Connect();
         _canalConnector.Subscribe(_canalOption.Subscribe);
         _canalConnector.Rollback();
         _canalTimer = new System.Threading.Timer(CanalGetData, null, _canalOption.Timer * 1000, _canalOption.Timer * 1000);
         _logger.LogInformation("canal client start success...");
         AppDomain.CurrentDomain.ProcessExit += CurrentDomainOnProcessExit;
     }
     catch (Exception ex)
     {
         _logger.LogError(ex, "canal client start error...");
     }
     return(Task.CompletedTask);
 }
Exemplo n.º 2
0
        public Task StartAsync(CancellationToken cancellationToken)
        {
            try
            {
                _canalConnector = CanalConnectors.NewSingleConnector(_canalOption.Host, _canalOption.Port, _canalOption.Destination, _canalOption.MysqlName, _canalOption.MysqlPwd);
                _canalConnector.Connect();
                _canalConnector.Subscribe(_canalOption.Subscribe);
                _canalConnector.Rollback();

                AppDomain.CurrentDomain.ProcessExit += CurrentDomainOnProcessExit;

                _logger.LogInformation("canal client start ...");
                LazyCanalGetEntities();
                LazyCanalDoWork();
                CanalServerAckStart();
            }
            catch (Exception ex)
            {
                _logger.LogError(ex, "canal client start error...");
            }
            return(Task.CompletedTask);
        }