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);
        }
 /// <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>
 ///     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>
 ///     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);
 }