public async Task Send(NamespaceContext context, IPipe <NamespaceContext> next)
        {
            await context.OneTimeSetup <ConfigureTopologyContext <TSettings> >(async payload =>
            {
                await ConfigureTopology(context).ConfigureAwait(false);

                context.GetOrAddPayload(() => _settings);
            }).ConfigureAwait(false);

            try
            {
                await next.Send(context).ConfigureAwait(false);
            }
            finally
            {
                if (_removeSubscriptions)
                {
                    try
                    {
                        await RemoveSubscriptions(context).ConfigureAwait(false);
                    }
                    catch (Exception ex)
                    {
                        if (_log.IsWarnEnabled)
                        {
                            _log.Warn("Failed to remove one or more subsriptions from the endpoint.", ex);
                        }
                    }
                }
            }
        }
        public async Task Send(NamespaceContext context, IPipe <NamespaceContext> next)
        {
            await context.OneTimeSetup <ConfigureTopologyContext <TSettings> >(async payload =>
            {
                await ConfigureTopology(context).ConfigureAwait(false);

                context.GetOrAddPayload(() => _settings);

                if (_removeSubscriptions)
                {
                    _cancellationToken.Register(async() =>
                    {
                        try
                        {
                            await RemoveSubscriptions(context).ConfigureAwait(false);
                        }
                        catch (Exception ex)
                        {
                            LogContext.Warning?.Log(ex, "Failed to remove one or more subscriptions from the endpoint.");
                        }
                    });
                }
            }, () => new Context()).ConfigureAwait(false);

            await next.Send(context).ConfigureAwait(false);
        }
        async Task ConfigureTopology(NamespaceContext context)
        {
            await context.OneTimeSetup <ConfigureTopologyContext <TSettings> >(async payload =>
            {
                await ConfigureTopology(context.ConnectionContext).ConfigureAwait(false);

                context.GetOrAddPayload(() => _settings);

                if (_removeSubscriptions)
                {
                    var logContext = LogContext.Current;
                    if (logContext == null)
                    {
                        throw new InvalidOperationException("The LogContext must be available");
                    }

                    // ReSharper disable once MethodSupportsCancellation
                    _cancellationToken.Register(() => TaskUtil.Await(async() =>
                    {
                        LogContext.SetCurrentIfNull(logContext);

                        try
                        {
                            await RemoveSubscriptions(context.ConnectionContext).ConfigureAwait(false);
                        }
                        catch (Exception ex)
                        {
                            LogContext.Warning?.Log(ex, "Failed to remove one or more subscriptions from the endpoint.");
                        }
                    }));
                }
            }, () => new Context()).ConfigureAwait(false);
        }