public void HandlerConfigured <T>(IHandlerConfigurator <T> configurator) where T : class { var specification = new ConcurrencyLimitConsumePipeSpecification <T>(Limiter); configurator.AddPipeSpecification(specification); }
public void Configure(IHandlerConfigurator <TMessage> configurator) { foreach (var configuration in Configurations) { configuration.Configure(configurator); } }
void IHandlerConfigurationObserver.HandlerConfigured <T>(IHandlerConfigurator <T> configurator) { var specification = new ConsumeContextRetryPipeSpecification <ConsumeContext <T>, RetryConsumeContext <T> >(Factory, _cancellationToken); _configure?.Invoke(specification); configurator.AddPipeSpecification(specification); }
void IHandlerConfigurationObserver.HandlerConfigured <T>(IHandlerConfigurator <T> configurator) { var specification = new TimeoutSpecification <T>(); _configure?.Invoke(specification); configurator.AddPipeSpecification(specification); }
public void HandlerConfigured <TMessage>(IHandlerConfigurator <TMessage> configurator) where TMessage : class { All(observer => { observer.HandlerConfigured(configurator); return(true); }); }
void IHandlerConfigurationObserver.HandlerConfigured <T>(IHandlerConfigurator <T> configurator) { var redeliverySpecification = new DelayedRedeliveryPipeSpecification <T>(); var retrySpecification = new RedeliveryRetryPipeSpecification <T>(); _configure?.Invoke(retrySpecification); configurator.AddPipeSpecification(redeliverySpecification); configurator.AddPipeSpecification(retrySpecification); }
/// <summary> /// Adds a message handler to the Apworks framework. (This operation only applies on CQRS architecture). /// </summary> /// <param name="configurator">The <see cref="IHandlerConfigurator"/> instance to be extended.</param> /// <param name="handlerKind">The <see cref="HandlerKind"/> which specifies the kind of the handler, can either be a Command or an Event.</param> /// <param name="sourceType">The <see cref="HandlerSourceType"/> which specifies the type of the source, can either be an Assembly or a Type.</param> /// <param name="source">The source name, if <paramref name="sourceType"/> is Assembly, the source name should be the assembly full name, if /// <paramref name="sourceType"/> is Type, the source name should be the assembly qualified name of the type.</param> /// <param name="name">The name of the message handler.</param> /// <returns>The <see cref="IHandlerConfigurator"/> instance.</returns> public static IHandlerConfigurator AddMessageHandler(this IHandlerConfigurator configurator, HandlerKind handlerKind, HandlerSourceType sourceType, string source, string name = null) { if (string.IsNullOrEmpty(name)) { return(new HandlerConfigurator(configurator, handlerKind, sourceType, source)); } else { return(new HandlerConfigurator(configurator, name, handlerKind, sourceType, source)); } }
/// <summary> /// Limits the number of concurrent messages consumed by the handler. /// </summary> /// <param name="configurator"></param> /// <param name="concurrentMessageLimit">The concurrent message limit for the handler message type</param> public static void UseConcurrentMessageLimit <TMessage>(this IHandlerConfigurator <TMessage> configurator, int concurrentMessageLimit) where TMessage : class { if (configurator == null) { throw new ArgumentNullException(nameof(configurator)); } var observer = new ConcurrencyLimitHandlerConfigurationObserver(concurrentMessageLimit); configurator.ConnectHandlerConfigurationObserver(observer); }
/// <summary> /// Includes an outbox in the consume filter path, which delays outgoing messages until the return path /// of the pipeline returns to the outbox filter. At this point, the message execution pipeline should be /// nearly complete with only the ack remaining. If an exception is thrown, the messages are not sent/published. /// </summary> /// <param name="configurator"></param> /// <param name="configure">Configure the outbox</param> public static void UseInMemoryOutbox <TMessage>(this IHandlerConfigurator <TMessage> configurator, Action <IOutboxConfigurator> configure = default) where TMessage : class { if (configurator == null) { throw new ArgumentNullException(nameof(configurator)); } var observer = new InMemoryOutboxHandlerConfigurationObserver(configure); configurator.ConnectHandlerConfigurationObserver(observer); }
/// <summary> /// Configures the message retry for the handler, regardless of message type. /// </summary> /// <param name="configurator"></param> /// <param name="configure"></param> public static void UseScheduledRedelivery <TMessage>(this IHandlerConfigurator <TMessage> configurator, Action <IRetryConfigurator> configure) where TMessage : class { if (configurator == null) { throw new ArgumentNullException(nameof(configurator)); } var observer = new MessageRedeliveryHandlerConfigurationObserver(configure); configurator.ConnectHandlerConfigurationObserver(observer); }
/// <summary> /// Configures the message retry for the consumer consumer, regardless of message type. /// </summary> /// <param name="configurator"></param> /// <param name="busFactoryConfigurator"> /// The bus factory configurator, to connect the observer, to cancel retries if the bus is stopped /// </param> /// <param name="configure"></param> public static void UseMessageRetry <TMessage>(this IHandlerConfigurator <TMessage> configurator, IBusFactoryConfigurator busFactoryConfigurator, Action <IRetryConfigurator> configure) where TMessage : class { if (configurator == null) { throw new ArgumentNullException(nameof(configurator)); } var retryObserver = new RetryBusObserver(); busFactoryConfigurator.ConnectBusObserver(retryObserver); var observer = new MessageRetryHandlerConfigurationObserver(retryObserver.Stopping, configure); configurator.ConnectHandlerConfigurationObserver(observer); }
/// <summary> /// Limits the number of concurrent messages consumed by the handler. /// </summary> /// <param name="configurator"></param> /// <param name="concurrentMessageLimit">The concurrent message limit for the handler 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 IHandlerConfigurator <TMessage> configurator, int concurrentMessageLimit, IManagementEndpointConfigurator managementEndpointConfigurator, string id = null) where TMessage : class { if (configurator == null) { throw new ArgumentNullException(nameof(configurator)); } var observer = new ConcurrencyLimitHandlerConfigurationObserver(concurrentMessageLimit, id); configurator.ConnectHandlerConfigurationObserver(observer); managementEndpointConfigurator.Instance(observer.Limiter, x => { x.UseConcurrentMessageLimit(1); x.Message <SetConcurrencyLimit>(m => m.UseRetry(r => r.None())); }); }
void IHandlerConfigurationObserver.HandlerConfigured <T>(IHandlerConfigurator <T> configurator) { var specification = new InMemoryOutboxSpecification <T>(); configurator.AddPipeSpecification(specification); }
/// <summary> /// Configures the Apworks framework by using the specified object container. /// </summary> /// <typeparam name="TObjectContainer">The type of the object container to be used by the framework.</typeparam> /// <param name="configurator">The <see cref="IHandlerConfigurator"/> instance to be extended.</param> /// <param name="initFromConfigFile">The <see cref="Boolean"/> value which indicates whether the container configuration should be read from the config file.</param> /// <param name="sectionName">The name of the section in the config file. This value must be specified when the <paramref name="initFromConfigFile"/> parameter is set to true.</param> /// <returns>The <see cref="IObjectContainerConfigurator"/> instance.</returns> public static IObjectContainerConfigurator UsingObjectContainer <TObjectContainer>(this IHandlerConfigurator configurator, bool initFromConfigFile = false, string sectionName = null) where TObjectContainer : IObjectContainer { return(new ObjectContainerConfigurator(configurator, typeof(TObjectContainer), initFromConfigFile, sectionName)); }
public void HandlerConfigured <TMessage>(IHandlerConfigurator <TMessage> configurator) where TMessage : class { _messageTypes.Add(typeof(TMessage)); }
public BrokerConfiguration(IMessageBroker messageBroker, IHandlerConfigurator handlerConfigurator, string host) { MessageBroker = messageBroker; HandlerConfigurator = handlerConfigurator; Host = host; }
/// <summary> /// Adds an exception handler to the Apworks framework. /// </summary> /// <typeparam name="TException">The type of the exception to be handled.</typeparam> /// <typeparam name="TExceptionHandler">The type of the exception handler.</typeparam> /// <param name="configurator">The <see cref="IHandlerConfigurator"/> to be extended.</param> /// <param name="behavior">The exception handling behavior.</param> /// <returns>The <see cref="IExceptionHandlerConfigurator"/> instance.</returns> public static IExceptionHandlerConfigurator AddExceptionHandler <TException, TExceptionHandler>(this IHandlerConfigurator configurator, ExceptionHandlingBehavior behavior = ExceptionHandlingBehavior.Direct) where TException : Exception where TExceptionHandler : IExceptionHandler { return(new ExceptionHandlerConfigurator(configurator, typeof(TException), typeof(TExceptionHandler), behavior)); }
public void HandlerConfigured <TMessage>(IHandlerConfigurator <TMessage> configurator) where TMessage : class { _busEndpointConfiguration.Consume.Configurator.HandlerConfigured(configurator); }
/// <summary> /// Registers an interceptor on the given method of a given type. /// </summary> /// <typeparam name="TInterceptor">The type of the interceptor to be registered.</typeparam> /// <typeparam name="TContract">The type which contains the method to be intercepted.</typeparam> /// <param name="configurator">The <see cref="IHandlerConfigurator"/> instance to be extended.</param> /// <param name="interceptMethod">The method to be intercepted.</param> /// <returns>The <see cref="IInterceptionConfigurator"/> instance.</returns> public static IInterceptionConfigurator RegisterInterception <TInterceptor, TContract>(this IHandlerConfigurator configurator, string interceptMethod) where TInterceptor : IInterceptor { return(new InterceptionConfigurator(configurator, typeof(TInterceptor), typeof(TContract), interceptMethod)); }
void IHandlerConfigurationObserver.HandlerConfigured <TMessage>(IHandlerConfigurator <TMessage> configurator) { _configurator.HandlerConfigured(configurator); }
public void HandlerConfigured <TMessage>(IHandlerConfigurator <TMessage> configurator) where TMessage : class { Consume.Configurator.HandlerConfigured(configurator); }
public void HandlerConfigured <TMessage>(IHandlerConfigurator <TMessage> configurator) where TMessage : class { _configuration.HandlerConfigured(configurator); }
/// <summary> /// 通过使用Autofac作为对象容器来配置OFoods框架. /// </summary> public static IObjectContainerConfigurator UseAutofacContainer(this IHandlerConfigurator configurator, bool initFromConfigFile = false, string configPath = null) { return(configurator.UsingObjectContainer <AutofacObjectContainer>(initFromConfigFile, configPath)); }
void IHandlerConfigurationObserver.HandlerConfigured <TMessage>(IHandlerConfigurator <TMessage> configurator) { NotifyObserver <TMessage>(); }
public void Configure(IHandlerConfigurator <TMessage> configurator) { _configure(configurator); }
/// <summary> /// Configures the Apworks framework by using Unity as the object container. /// </summary> /// <param name="configurator">The <see cref="IHandlerConfigurator"/> instance to be extended.</param> /// <param name="initFromConfigFile">The <see cref="System.Boolean"/> value which indicates whether the container configuration should be read from the config file.</param> /// <param name="sectionName">The name of the section in the config file. This value must be specified when the <paramref name="initFromConfigFile"/> parameter is set to true.</param> /// <returns>The <see cref="IObjectContainerConfigurator"/> instace.</returns> public static IObjectContainerConfigurator UsingUnityContainer(this IHandlerConfigurator configurator, bool initFromConfigFile = false, string sectionName = null) { return(configurator.UsingObjectContainer <UnityObjectContainer>(initFromConfigFile, sectionName)); }
public void Configure(IHandlerConfigurator <TMessage> configurator) { // do nothing }
public void HandlerConfigured <TMessage>(IHandlerConfigurator <TMessage> configurator) where TMessage : class { _handlerObservers.HandlerConfigured(configurator); }
void IHandlerConfigurationObserver.HandlerConfigured <T>(IHandlerConfigurator <T> configurator) { var specification = new PrometheusHandlerSpecification <T>(); configurator.AddPipeSpecification(specification); }