Ejemplo n.º 1
0
        /// <summary>
        /// Configure send params for FIFO queues.
        /// </summary>
        /// <param name="sendPipeline">Send pipeline configurator.</param>
        /// <param name="types">Types for fifo send approach.</param>
        /// <exception cref="ArgumentNullException"/>
        public static void ConfigureSendEndpointAsFifoForTypes(this ISendPipelineConfigurator sendPipeline, IEnumerable <Type> types)
        {
            if (sendPipeline == null)
            {
                throw new ArgumentNullException(nameof(sendPipeline));
            }
            if (types == null)
            {
                throw new ArgumentNullException(nameof(types));
            }

            sendPipeline.ConfigureSend(configurator =>
                                       configurator.UseSendExecute(context =>
            {
                if (context.GetType().GenericTypeArguments.NullSafeAny(types.Contains))
                {
                    // для упорядочевания внутри группы, aws упорядочевает только внутри группы
                    context.SetGroupId("68FE43E8-B5F1-4FB4-83DF-7A6B35F19C53");

                    // ключ уникальности
                    if (context.CorrelationId != null)
                    {
                        context.SetDeduplicationId(context.CorrelationId.ToString());
                    }
                }
            }));
        }
 /// <summary>
 /// Add support for ApplicationInsight to track all send message on the bus.
 /// </summary>
 public static void UseApplicationInsightsOnSend(this ISendPipelineConfigurator configurator,
                                                 TelemetryClient telemetryClient,
                                                 Action <IOperationHolder <DependencyTelemetry>, SendContext> configureOperation = null,
                                                 string telemetryHeaderRootKey   = ApplicationInsightsDefaultConfiguration.DefaultTelemetryHeaderRootKey,
                                                 string telemetryHeaderParentKey = ApplicationInsightsDefaultConfiguration.DefaultTelemetryHeaderParentKey)
 {
     configurator.ConfigureSend(x => x.Connect(new TelemetrySendPipeSpecificationObserver(telemetryClient, telemetryHeaderRootKey,
                                                                                          telemetryHeaderParentKey, configureOperation)));
 }
Ejemplo n.º 3
0
        /// <summary>
        /// Use scoped filter for <see cref="SendContext{T}" />
        /// </summary>
        /// <param name="configurator"></param>
        /// <param name="filterType">Filter type</param>
        /// <param name="lifetimeScopeProvider">Lifetime Scope Provider</param>
        public static void UseSendFilter(this ISendPipelineConfigurator configurator, Type filterType, ILifetimeScopeProvider lifetimeScopeProvider)
        {
            if (configurator == null)
            {
                throw new ArgumentNullException(nameof(configurator));
            }
            if (lifetimeScopeProvider == null)
            {
                throw new ArgumentNullException(nameof(lifetimeScopeProvider));
            }

            var observer = new ScopedSendPipeSpecificationObserver(filterType, lifetimeScopeProvider);

            configurator.ConfigureSend(cfg => cfg.ConnectSendPipeSpecificationObserver(observer));
        }
        /// <summary>
        /// Use scoped filter for <see cref="SendContext{T}" />
        /// </summary>
        /// <param name="configurator"></param>
        /// <param name="filterType">Filter type</param>
        /// <param name="registration">Registration Context</param>
        public static void UseSendFilter(this ISendPipelineConfigurator 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 ScopedSendPipeSpecificationObserver(filterType, provider);

            configurator.ConfigureSend(cfg => cfg.ConnectSendPipeSpecificationObserver(observer));
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Use scoped filter for <see cref="SendContext{T}" />
        /// </summary>
        /// <param name="configurator"></param>
        /// <param name="filterType">Filter type</param>
        /// <param name="provider">Configuration service provider</param>
        public static void UseSendFilter(this ISendPipelineConfigurator 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.UseSendFilter(filterType, lifetimeScopeProvider);
        }
Ejemplo n.º 6
0
 protected abstract void ConfigureFilter(ISendPipelineConfigurator sendPipelineConfigurator);
Ejemplo n.º 7
0
 protected override void ConfigureFilter(ISendPipelineConfigurator configurator)
 {
     AutofacFilterExtensions.UseSendFilter(configurator, typeof(ScopedFilter <>), Registration);
 }
 /// <summary>
 /// Use scope for Send
 /// </summary>
 /// <param name="configurator">The send pipe configurator</param>
 /// <param name="scopeProvider">SendScopeProvider</param>
 public static void UseSendScope(this ISendPipelineConfigurator configurator, ISendScopeProvider scopeProvider)
 {
     configurator.ConfigureSend(cfg => cfg.ConnectSendPipeSpecificationObserver(new ScopeSendPipeSpecificationObserver(scopeProvider)));
 }
 /// <summary>
 /// Configure the pipeline to use a filter that adds current logging scope to the headers of sended message
 /// </summary>
 public static void UseSendLoggingScope(this ISendPipelineConfigurator configurator, IServiceProvider serviceProvider) =>
 configurator.ConfigureSend(cfg => cfg.AddPipeSpecification(
                                new LoggingScopeSendFilterSpecification(serviceProvider.GetScopeAccessor())));