/// <summary> /// Sets up a message handler chain for the bus publisher /// </summary> /// <typeparam name="TMessageType">The message type</typeparam> /// <param name="options">The options</param> /// <param name="configureMessageHandlerChain">The action called to setup the message handler chain</param> /// <returns>Bus options</returns> public static BusOptions <TMessageType> UseSubscriptionChain <TMessageType>( this BusOptions <TMessageType> options, Action <ChainBuilder <MessageAndHandler <TMessageType> > > configureMessageHandlerChain) { var builder = new ChainBuilder <MessageAndHandler <TMessageType> >(); configureMessageHandlerChain(builder); return(UseSubscriptionChain(options, builder)); }
/// <summary> /// Sets up a message handler chain for the bus publisher /// </summary> /// <typeparam name="TMessageType">The message type</typeparam> /// <param name="options">The options</param> /// <param name="configureMessageHandlerChain">The action called to setup the message handler chain</param> /// <returns>Bus options</returns> public static BusOptions <TMessageType> UseSubscriptionChain <TMessageType>( this BusOptions <TMessageType> options, Action <ChainBuilder <MessageAndHandler <TMessageType> >, Func <MessageAndHandler <TMessageType>, CancellationToken, Task> > configureMessageHandlerChain) { var builder = new ChainBuilder <MessageAndHandler <TMessageType> >(); configureMessageHandlerChain(builder, PublishToSubscription.PublishAsync); return(UseSubscriptionChain(options, builder)); }
private static BusOptions <TMessageType> UseSubscriptionChain <TMessageType>( BusOptions <TMessageType> options, ChainBuilder <MessageAndHandler <TMessageType> > builder) { if (builder.HasHandler == false) { builder.Handler(PublishToSubscription.PublishAsync); } var subscriptionNotification = new ChainBuilderNotifier(); var services = new ChainBuilderSetupServices(subscriptionNotification); var chainFunc = builder.BuildFunc(services); var newChain = new Chain <MessageAndHandler <TMessageType> >(chainFunc); subscriptionNotification.Notify(newChain); options.UseCustomPublisher(new ParallelMessageHandlerChainPublisher <TMessageType>(chainFunc)); return(options); }
public ConcurrentMessageBus(BusOptions <TMessageType> options) : base(options) { }
/// <summary> /// Initializes a new instance of the <see cref="Bus{TMessageType}"/> class. /// </summary> /// <param name="options"> /// The options /// </param> public Bus(BusOptions <TMessageType> options) { this.options = options; this.publishAsyncFunc = this.options.CustomPublishFunc ?? this.publishAsyncFunc; }
/// <summary> /// Use a single receiver publisher /// </summary> /// <typeparam name="TMessageType">The message type</typeparam> /// <param name="options">The options</param> /// <param name="customHandlerMethod">The custom </param> /// <returns>The options</returns> public static BusOptions <TMessageType> UseSingleReceiverPublisher <TMessageType>( this BusOptions <TMessageType> options, Func <Func <TMessageType, CancellationToken, Task>, TMessageType, CancellationToken, Task> customHandlerMethod = null) { return(options.UseCustomPublisher(new SingleReceiverPublisher <TMessageType>(customHandlerMethod))); }
/// <summary> /// Use the serial publisher. Only a single subscription handler is executed at a time. /// </summary> /// <typeparam name="TMessageType">The message type</typeparam> /// <param name="options">The options</param> /// <returns>The options</returns> public static BusOptions <TMessageType> UseSerialPublisher <TMessageType>(this BusOptions <TMessageType> options) { return(options.UseCustomPublisher(SerialPublisher <TMessageType> .Default)); }
/// <summary> /// Configures the bus to use the forced parallel publisher. Every message subscription handler is executed on a newly /// spawned Task /// </summary> /// <typeparam name="TMessageType"> /// The message type /// </typeparam> /// <param name="options"> /// The options /// </param> /// <returns> /// The options /// </returns> public static BusOptions <TMessageType> UseForcedParallelPublisher <TMessageType>(this BusOptions <TMessageType> options) { options.UseCustomPublisher(ForcedParallelPublisher <TMessageType> .Default); return(options); }