コード例 #1
0
        protected override async Task StopSupervisor(StopSupervisorContext context)
        {
            LogContext.Debug?.Log("Stopping consumer: {InputAddress}", _context.InputAddress);

            SetCompleted(ActiveAndActualAgentsCompleted(context));

            await Completed.ConfigureAwait(false);
        }
コード例 #2
0
        protected override async Task StopSupervisor(StopSupervisorContext context)
        {
            if (_log.IsDebugEnabled)
                _log.DebugFormat("Stopping consumer: {0}", _context.InputAddress);

            SetCompleted(ActiveAndActualAgentsCompleted(context));

            await Completed.ConfigureAwait(false);
        }
コード例 #3
0
        protected override async Task StopSupervisor(StopSupervisorContext context)
        {
            LogContext.Debug?.Log("Stopping receiver: {InputAddress}", _context.InputAddress);

            SetCompleted(ActiveAndActualAgentsCompleted(context));

            await Completed.ConfigureAwait(false);

            await _context.CloseAsync(context.CancellationToken).ConfigureAwait(false);
        }
コード例 #4
0
        protected override async Task StopAgent(StopContext context)
        {
            _messageConsumer.Stop();
            _messageConsumer.Listener -= HandleMessage;
            _messageConsumer.Start();

            SetCompleted(ActiveAndActualAgentsCompleted(context));

            await Completed.ConfigureAwait(false);
        }
コード例 #5
0
        public async Task Send(T context, IPipe <T> next)
        {
            await _context.TransportObservers.NotifyReady(_context.InputAddress).ConfigureAwait(false);

            SetReady();

            await next.Send(context).ConfigureAwait(false);

            await Completed.ConfigureAwait(false);
        }
コード例 #6
0
        protected override async Task StopAgent(StopContext context)
        {
            await _consumerContext.Close().ConfigureAwait(false);

            _consumerContext.ErrorHandler -= HandleKafkaError;

            LogContext.Debug?.Log("Stopping consumer: {InputAddress}", _context.InputAddress);

            SetCompleted(ActiveAndActualAgentsCompleted(context));

            await Completed.ConfigureAwait(false);
        }
コード例 #7
0
        public override async Task <HostHandle> Start()
        {
            var handlesReady = new TaskCompletionSource <HostReceiveEndpointHandle[]>();
            var hostStarted  = new TaskCompletionSource <bool>();

            IPipe <HttpHostContext> connectionPipe = Pipe.ExecuteAsync <HttpHostContext>(async context =>
            {
                if (_log.IsDebugEnabled)
                {
                    _log.DebugFormat("Connection established to {0}", Settings.Host);
                }

                try
                {
                    await handlesReady.Task.ConfigureAwait(false);

                    await context.Start(context.CancellationToken).ConfigureAwait(false);

                    hostStarted.TrySetResult(true);

                    await Completed.ConfigureAwait(false);
                }
                catch (OperationCanceledException ex)
                {
                    hostStarted.TrySetException(ex);
                }
                catch (Exception ex)
                {
                    hostStarted.TrySetException(ex);
                    throw;
                }
            });

            if (_log.IsDebugEnabled)
            {
                _log.DebugFormat("Starting connection to {0}", Settings.Host);
            }

            var connectionTask = HttpHostContextSupervisor.Send(connectionPipe, Stopping);

            HostReceiveEndpointHandle[] handles = ReceiveEndpoints.StartEndpoints();

            var hostHandle = new Handle(handles, this, _httpHostContextSupervisor, connectionTask);

            await hostHandle.Ready.ConfigureAwait(false);

            handlesReady.TrySetResult(handles);

            await hostStarted.Task.ConfigureAwait(false);

            return(hostHandle);
        }
コード例 #8
0
        protected override async Task StopSupervisor(StopSupervisorContext context)
        {
            if (_log.IsDebugEnabled)
            {
                _log.DebugFormat("Stopping receiver: {0}", _context.InputAddress);
            }

            SetCompleted(ActiveAndActualAgentsCompleted(context));

            await Completed.ConfigureAwait(false);

            await _context.CloseAsync(context.CancellationToken).ConfigureAwait(false);
        }
コード例 #9
0
        protected override async Task StopAgent(StopContext context)
        {
            await _processorContext.StopProcessingAsync().ConfigureAwait(false);

            _processorContext.ProcessEvent -= HandleMessage;
            _processorContext.ProcessError -= HandleError;

            await _executor.DisposeAsync().ConfigureAwait(false);

            LogContext.Debug?.Log("Stopping consumer: {InputAddress}", _context.InputAddress);

            SetCompleted(ActiveAndActualAgentsCompleted(context));

            await Completed.ConfigureAwait(false);
        }
コード例 #10
0
ファイル: HttpHost.cs プロジェクト: youqingz/MassTransit
        public override async Task <HostHandle> Start(CancellationToken cancellationToken)
        {
            LogContext.Debug?.Log("Starting host: {HostAddress}", _hostConfiguration.HostAddress);

            DefaultLogContext = LogContext.Current;
            SendLogContext    = LogContext.Current.CreateLogContext(LogCategoryName.Transport.Send);
            ReceiveLogContext = LogContext.Current.CreateLogContext(LogCategoryName.Transport.Receive);

            var handlesReady = TaskUtil.GetTask <HostReceiveEndpointHandle[]>();
            var hostStarted  = TaskUtil.GetTask <bool>();

            IPipe <HttpHostContext> connectionPipe = Pipe.ExecuteAsync <HttpHostContext>(async context =>
            {
                try
                {
                    await handlesReady.Task.ConfigureAwait(false);

                    await context.Start(context.CancellationToken).ConfigureAwait(false);

                    hostStarted.TrySetResult(true);

                    await Completed.ConfigureAwait(false);
                }
                catch (OperationCanceledException ex)
                {
                    hostStarted.TrySetException(ex);
                }
                catch (Exception ex)
                {
                    hostStarted.TrySetException(ex);
                    throw;
                }
            });

            var connectionTask = HttpHostContextSupervisor.Send(connectionPipe, Stopping);

            HostReceiveEndpointHandle[] handles = ReceiveEndpoints.StartEndpoints(cancellationToken);

            HostHandle hostHandle = new StartHostHandle(this, handles, GetAgentHandles());

            await hostHandle.Ready.ConfigureAwait(false);

            handlesReady.TrySetResult(handles);

            await hostStarted.Task.ConfigureAwait(false);

            return(hostHandle);
        }
コード例 #11
0
        protected override async Task StopSupervisor(StopSupervisorContext context)
        {
            LogContext.Debug?.Log("Stopping Consumer: {InputAddress} - {ConsumerTag}", _context.InputAddress, _consumerTag);

            SetCompleted(ActiveAndActualAgentsCompleted(context));

            try
            {
                await Completed.ConfigureAwait(false);
            }
            catch (OperationCanceledException)
            {
                foreach (var pendingContext in _pending.Values)
                {
                    pendingContext.Cancel();
                }

                throw;
            }
        }
コード例 #12
0
        protected override async Task StopSupervisor(StopSupervisorContext context)
        {
            if (_log.IsDebugEnabled)
            {
                _log.DebugFormat("Stopping consumer: {0}", _receiveEndpointContext.InputAddress);
            }

            SetCompleted(ActiveAndActualAgentsCompleted(context));

            try
            {
                await Completed.UntilCompletedOrTimeout(TimeSpan.FromSeconds(30)).ConfigureAwait(false);
            }
            catch (TimeoutException)
            {
                foreach (var pendingContext in _pending.Values)
                {
                    pendingContext.Cancel();
                }
            }

            await Completed.ConfigureAwait(false);
        }
コード例 #13
0
        protected override async Task StopAgent(StopContext context)
        {
            SetCompleted(ActiveAndActualAgentsCompleted(context));

            await Completed.ConfigureAwait(false);
        }