/// <summary>
 /// Add support for ApplicationInsights to the pipeline, which will be used to track all message publication.
 /// </summary>
 public static void UseApplicationInsightsOnPublish(this IPublishPipelineConfigurator configurator,
                                                    TelemetryClient telemetryClient,
                                                    Action <IOperationHolder <DependencyTelemetry>, PublishContext> configureOperation = null,
                                                    string telemetryHeaderRootKey   = ApplicationInsightsDefaultConfiguration.DefaultTelemetryHeaderRootKey,
                                                    string telemetryHeaderParentKey = ApplicationInsightsDefaultConfiguration.DefaultTelemetryHeaderParentKey)
 {
     configurator.ConfigurePublish(x => x.Connect(new TelemetryPublishPipeSpecificationObserver(telemetryClient, telemetryHeaderRootKey,
                                                                                                telemetryHeaderParentKey, configureOperation)));
 }
Пример #2
0
 /// <summary>
 /// Add support for ApplicationInsights to the pipeline, which will be used to track all message publication.
 /// </summary>
 /// <param name="configurator"></param>
 /// <param name="telemetryClient">Telemetry client</param>
 /// <param name="configureOperation">Add additional information to operation</param>
 public static void UseApplicationInsightsOnPublish(this IPublishPipelineConfigurator configurator,
                                                    TelemetryClient telemetryClient,
                                                    Action <IOperationHolder <DependencyTelemetry>, PublishContext> configureOperation = null)
 {
     configurator.ConfigurePublish(pipeConfigurator =>
     {
         var specification = new ApplicationInsightsPublishSpecification <PublishContext>(telemetryClient, configureOperation);
         pipeConfigurator.AddPipeSpecification(specification);
     });
 }
Пример #3
0
        /// <summary>
        /// Use scoped filter for <see cref="PublishContext{T}" />
        /// </summary>
        /// <param name="configurator"></param>
        /// <param name="filterType">Filter type</param>
        /// <param name="lifetimeScopeProvider">Lifetime Scope Provider</param>
        public static void UsePublishFilter(this IPublishPipelineConfigurator configurator, Type filterType, ILifetimeScopeProvider lifetimeScopeProvider)
        {
            if (configurator == null)
            {
                throw new ArgumentNullException(nameof(configurator));
            }
            if (lifetimeScopeProvider == null)
            {
                throw new ArgumentNullException(nameof(lifetimeScopeProvider));
            }

            var observer = new ScopedPublishPipeSpecificationObserver(filterType, lifetimeScopeProvider);

            configurator.ConfigurePublish(cfg => cfg.ConnectPublishPipeSpecificationObserver(observer));
        }
        /// <summary>
        /// Use scoped filter for <see cref="PublishContext{T}" />
        /// </summary>
        /// <param name="configurator"></param>
        /// <param name="filterType">Filter type</param>
        /// <param name="registration">Registration Context</param>
        public static void UsePublishFilter(this IPublishPipelineConfigurator configurator, Type filterType, IRegistration registration)
        {
            if (configurator == null)
            {
                throw new ArgumentNullException(nameof(configurator));
            }
            if (registration == null)
            {
                throw new ArgumentNullException(nameof(registration));
            }

            var provider = registration.GetRequiredService <IServiceProvider>();
            var observer = new ScopedPublishPipeSpecificationObserver(filterType, provider);

            configurator.ConfigurePublish(cfg => cfg.ConnectPublishPipeSpecificationObserver(observer));
        }
Пример #5
0
        /// <summary>
        /// Use scoped filter for <see cref="PublishContext{T}" />
        /// </summary>
        /// <param name="configurator"></param>
        /// <param name="filterType">Filter type</param>
        /// <param name="provider">Configuration service provider</param>
        public static void UsePublishFilter(this IPublishPipelineConfigurator configurator, Type filterType, IConfigurationServiceProvider provider)
        {
            if (configurator == null)
            {
                throw new ArgumentNullException(nameof(configurator));
            }
            if (provider == null)
            {
                throw new ArgumentNullException(nameof(provider));
            }

            var lifetimeScope = provider.GetRequiredService <ILifetimeScope>();
            ILifetimeScopeProvider lifetimeScopeProvider = new SingleLifetimeScopeProvider(lifetimeScope);

            configurator.UsePublishFilter(filterType, lifetimeScopeProvider);
        }
        /// <summary>
        /// Sets the Fault Address for a Publish Endpoint.
        /// </summary>
        /// <param name="publishPipelineConfigurator">The <see cref="IPublishPipelineConfigurator"/> on which to set the Fault address. </param>
        /// <param name="faultAddress"> The <see cref="Uri" /> to be used for Faulted messages. </param>
        /// <returns>The <see cref="IPublishPipelineConfigurator"/>. </returns>
        public static IPublishPipelineConfigurator UseFaultAddress <T>([NotNull] this IPublishPipelineConfigurator publishPipelineConfigurator, [NotNull] Uri faultAddress)
            where T : class
        {
            if (publishPipelineConfigurator == null)
            {
                throw new ArgumentNullException(nameof(publishPipelineConfigurator));
            }
            if (faultAddress == null)
            {
                throw new ArgumentNullException(nameof(faultAddress));
            }

            publishPipelineConfigurator.ConfigurePublish(x =>
            {
                x.AddPipeSpecification(new DelegatePipeSpecification <PublishContext <T> >(p =>
                {
                    p.FaultAddress = faultAddress;
                }));
            });

            return(publishPipelineConfigurator);
        }
 /// <summary>
 /// Use scope for Send
 /// </summary>
 /// <param name="configurator">The publish pipe configurator</param>
 /// <param name="scopeProvider">PublishScopeProvider</param>
 public static void UsePublishScope(this IPublishPipelineConfigurator configurator, IPublishScopeProvider scopeProvider)
 {
     configurator.ConfigurePublish(cfg => cfg.ConnectPublishPipeSpecificationObserver(new ScopePublishPipeSpecificationObserver(scopeProvider)));
 }
Пример #8
0
 protected abstract void ConfigureFilter(IPublishPipelineConfigurator publishPipelineConfigurator);
 protected override void ConfigureFilter(IPublishPipelineConfigurator configurator)
 {
     AutofacFilterExtensions.UsePublishFilter(configurator, typeof(ScopedFilter <>), Registration);
 }
 /// <summary>
 /// Configure the pipeline to use a filter that adds current logging scope to the headers of published message
 /// </summary>
 public static void UsePublishLoggingScope(this IPublishPipelineConfigurator configurator, IServiceProvider serviceProvider) =>
 configurator.ConfigurePublish(cfg => cfg.AddPipeSpecification(
                                   new LoggingScopeSendFilterSpecification(serviceProvider.GetScopeAccessor())));