protected override void ConfigureInputQueueEndpoint(IReceiveEndpointConfigurator configurator)
        {
            _consumer = new OneMessageConsumer(GetTask<MessageA>());

            object instance = _consumer;

            configurator.Instance(instance);
        }
        protected override void ConfigureInputQueueEndpoint(IReceiveEndpointConfigurator configurator)
        {
            _consumer = new OneMessageConsumer(GetTask <MessageA>());

            object instance = _consumer;

            configurator.Instance(instance);
        }
        /// <summary>
        /// Limits the number of concurrent messages consumed on the receive endpoint, regardless of message type.
        /// </summary>
        /// <param name="configurator"></param>
        /// <param name="concurrentMessageLimit">The concurrency limit for the subsequent filters in the pipeline</param>
        /// <param name="managementEndpointConfigurator">A management endpoint configurator to support runtime adjustment</param>
        /// <param name="id">An identifier for the concurrency limit to allow selective adjustment</param>
        public static void UseConcurrencyLimit(this IConsumePipeConfigurator configurator, int concurrentMessageLimit,
                                               IReceiveEndpointConfigurator managementEndpointConfigurator, string id = default)
        {
            if (configurator == null)
            {
                throw new ArgumentNullException(nameof(configurator));
            }

            var observer = new ConcurrencyLimitConfigurationObserver(configurator, concurrentMessageLimit, id);

            managementEndpointConfigurator.Instance(observer.Limiter, x =>
            {
                x.UseConcurrentMessageLimit(1);
                x.Message <SetConcurrencyLimit>(m => m.UseRetry(r => r.None()));
            });
        }
        /// <summary>
        /// Limits the number of concurrent messages consumed by the saga, regardless of message type.
        /// </summary>
        /// <param name="configurator"></param>
        /// <param name="concurrentMessageLimit">The concurrent message limit for all message types for the saga</param>
        /// <param name="managementEndpointConfigurator">A management endpoint configurator to support runtime adjustment</param>
        /// <param name="id">An identifier for the concurrency limit to allow selective adjustment</param>
        public static void UseConcurrentMessageLimit <TSaga>(this ISagaConfigurator <TSaga> configurator, int concurrentMessageLimit,
                                                             IReceiveEndpointConfigurator managementEndpointConfigurator, string id = null)
            where TSaga : class, ISaga
        {
            if (configurator == null)
            {
                throw new ArgumentNullException(nameof(configurator));
            }

            var observer = new ConcurrencyLimitSagaConfigurationObserver <TSaga>(configurator, concurrentMessageLimit, id);

            configurator.ConnectSagaConfigurationObserver(observer);

            managementEndpointConfigurator.Instance(observer.Limiter, x =>
            {
                x.UseConcurrentMessageLimit(1);
                x.Message <SetConcurrencyLimit>(m => m.UseRetry(r => r.None()));
            });
        }
        /// <summary>
        /// Limits the number of concurrent messages consumed for the specified message type.
        /// </summary>
        /// <param name="configurator"></param>
        /// <param name="concurrentMessageLimit">The concurrent message limit for the message type</param>
        /// <param name="managementEndpointConfigurator">A management endpoint configurator to support runtime adjustment</param>
        /// <param name="id">An identifier for the concurrency limit to allow selective adjustment</param>
        public static void UseConcurrentMessageLimit <TMessage>(this IPipeConfigurator <ConsumeContext <TMessage> > configurator, int concurrentMessageLimit,
                                                                IReceiveEndpointConfigurator managementEndpointConfigurator, string id = null)
            where TMessage : class
        {
            if (configurator == null)
            {
                throw new ArgumentNullException(nameof(configurator));
            }

            var limiter = new ConcurrencyLimiter(concurrentMessageLimit, id);

            var specification = new ConcurrencyLimitConsumePipeSpecification <TMessage>(limiter);

            configurator.AddPipeSpecification(specification);

            managementEndpointConfigurator.Instance(limiter, x =>
            {
                x.UseConcurrentMessageLimit(1);
                x.Message <SetConcurrencyLimit>(m => m.UseRetry(r => r.None()));
            });
        }
Esempio n. 6
0
 public static void SubscriberFor <T>(this IReceiveEndpointConfigurator x, Func <ConsumeContext <T>, ISubscribe <T> > service) where T : class =>
 x.Instance(new Consumer <T>(service));
Esempio n. 7
0
 public void Configure(IReceiveEndpointConfigurator configurator)
 {
     configurator.Instance(_consumer);
 }
Esempio n. 8
0
 protected override void ConfigureConsumer(IReceiveEndpointConfigurator endpointConfigurator, IConsumerConfigurator <OrderPlacedConsumer> consumerConfigurator)
 {
     endpointConfigurator.Instance(new OrderPlacedResponseConsumer());
 }