Example #1
0
        public 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
                {
                    HostReceiveEndpointHandle[] endpointHandles = 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 = HttpHostCache.Send(connectionPipe, Stopping);

            HostReceiveEndpointHandle[] handles = ReceiveEndpoints.StartEndpoints();

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

            await hostHandle.Ready.ConfigureAwait(false);

            handlesReady.TrySetResult(handles);

            await hostStarted.Task.ConfigureAwait(false);

            return(hostHandle);
        }
Example #2
0
        public async Task <HostHandle> Start()
        {
            if (_handle != null)
            {
                throw new MassTransitException($"The host was already started: {_settings.ToDebugString()}");
            }

            HostReceiveEndpointHandle[] handles = ReceiveEndpoints.StartEndpoints();

            _handle = new Handle(handles, this, ConnectionCache);

            return(_handle);
        }
Example #3
0
        public async Task <HostHandle> Start()
        {
            if (_handle != null)
            {
                throw new MassTransitException($"The host was already started: {_hostConfiguration.Description}");
            }

            HostReceiveEndpointHandle[] handles = _receiveEndpoints.StartEndpoints();

            _handle = new StartHostHandle(this, handles);

            return(_handle);
        }
Example #4
0
        public virtual Task <HostHandle> Start()
        {
            if (_handle != null)
            {
                throw new MassTransitException($"The host was already started: {_hostConfiguration.HostAddress}");
            }

            HostReceiveEndpointHandle[] handles = _receiveEndpoints.StartEndpoints();

            _handle = new StartHostHandle(this, handles, GetAgentHandles());

            return(Task.FromResult(_handle));
        }
Example #5
0
        public async Task <HostHandle> Start()
        {
            TaskCompletionSource <HostReceiveEndpointHandle[]> handlesReady = new TaskCompletionSource <HostReceiveEndpointHandle[]>();
            TaskCompletionSource <bool> hostStarted = new TaskCompletionSource <bool>();

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

                try
                {
                    var endpointHandles = await handlesReady.Task.ConfigureAwait(false);

                    context.StartHost();

                    hostStarted.TrySetResult(true);

                    //Wait until someone shuts down the bus - Parked thread.
                    await _supervisor.StopRequested.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 = OwinHostCache.Send(connectionPipe, _supervisor.StoppingToken);

            HostReceiveEndpointHandle[] handles = ReceiveEndpoints.StartEndpoints();

            handlesReady.TrySetResult(handles);

            await hostStarted.Task.ConfigureAwait(false);

            return(new Handle(connectionTask, handles, _supervisor, this));
        }
Example #6
0
        public virtual Task <HostHandle> Start(CancellationToken cancellationToken)
        {
            if (_handle != null)
            {
                throw new MassTransitException($"The host was already started: {_hostConfiguration.HostAddress}");
            }

            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);

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

            _handle = new StartHostHandle(this, handles, GetAgentHandles());

            return(Task.FromResult(_handle));
        }
Example #7
0
        public async Task <HostHandle> Start()
        {
            HostReceiveEndpointHandle[] handles = ReceiveEndpoints.StartEndpoints();

            return(new Handle(this, handles));
        }
Example #8
0
        public async Task <HostHandle> Start()
        {
            HostReceiveEndpointHandle[] handles = await ReceiveEndpoints.StartEndpoints().ConfigureAwait(false);

            return(new Handle(this, _supervisor, handles));
        }
Example #9
0
        async Task <HostHandle> IBusHostControl.Start()
        {
            HostReceiveEndpointHandle[] handles = ReceiveEndpoints.StartEndpoints();

            return(new StartHostHandle(this, handles, NamespaceContextSupervisor, MessagingFactoryContextSupervisor));
        }