public ConnectHandle ConnectSendObserver(ISendObserver observer) { LogContext.SetCurrentIfNull(_logContext); return(_host.ConnectSendObserver(observer)); }
ConnectHandle IReceiveEndpointObserverConnector.ConnectReceiveEndpointObserver(IReceiveEndpointObserver observer) { LogContext.SetCurrentIfNull(_logContext); return(_host.ConnectReceiveEndpointObserver(observer)); }
ConnectHandle IConsumeMessageObserverConnector.ConnectConsumeMessageObserver <T>(IConsumeMessageObserver <T> observer) { LogContext.SetCurrentIfNull(_logContext); return(_host.ConnectConsumeMessageObserver(observer)); }
public async Task <BusHandle> StartAsync(CancellationToken cancellationToken) { LogContext.SetCurrentIfNull(_logContext); if (_busHandle != null) { LogContext.Warning?.Log("StartAsync called, but the bus was already started: {Address} ({Reason})", Address, "Already Started"); return(_busHandle); } await _busObservable.PreStart(this).ConfigureAwait(false); Handle busHandle = null; CancellationTokenSource tokenSource = null; try { if (cancellationToken == default) { tokenSource = new CancellationTokenSource(TimeSpan.FromSeconds(60)); cancellationToken = tokenSource.Token; } var hostHandle = _host.Start(cancellationToken); busHandle = new Handle(hostHandle, this, _busObservable, _logContext); try { await busHandle.Ready.OrCanceled(cancellationToken).ConfigureAwait(false); } catch (OperationCanceledException exception) when(exception.CancellationToken == cancellationToken) { try { await busHandle.StopAsync(TimeSpan.FromSeconds(30)).ConfigureAwait(false); } catch (Exception ex) { LogContext.Warning?.Log(ex, "Bus start faulted, and failed to stop host"); } await busHandle.Ready.ConfigureAwait(false); } await _busObservable.PostStart(this, busHandle.Ready).ConfigureAwait(false); _busHandle = busHandle; return(_busHandle); } catch (Exception ex) { try { if (busHandle != null) { LogContext.Debug?.Log("Bus start faulted, stopping host"); await busHandle.StopAsync(cancellationToken).ConfigureAwait(false); } } catch (OperationCanceledException) { } catch (Exception stopException) { LogContext.Warning?.Log(stopException, "Bus start faulted, and failed to stop host"); } await _busObservable.StartFaulted(this, ex).ConfigureAwait(false); throw; } finally { tokenSource?.Dispose(); } }
Task <ISendEndpoint> ISendEndpointProvider.GetSendEndpoint(Uri address) { LogContext.SetCurrentIfNull(_logContext); return(_receiveEndpoint.GetSendEndpoint(address)); }
Task IPublishEndpoint.Publish <T>(object values, IPipe <PublishContext> publishPipe, CancellationToken cancellationToken) { LogContext.SetCurrentIfNull(_logContext); return(_publishEndpoint.Publish <T>(values, publishPipe, cancellationToken)); }