示例#1
0
        public Distributor(IWorkerSelectionStrategy <TMessage> workerSelectionStrategy)
        {
            _selectionStrategy = workerSelectionStrategy;

            _fiber     = new PoolFiber();
            _scheduler = new TimerScheduler(new PoolFiber());
        }
        /// <summary>
        /// Implements a distributor-to-worker pattern for the given message type.
        /// </summary>
        /// <typeparam name="T">The type of to use the distributor</typeparam>
        /// <param name="configurator">Service bus to implement the distributor</param>
        /// <param name="endpointFactory">Factory to generate endpoints from a given URL</param>
        /// <param name="workerSelectionStrategy">The <code>IWorkerSelectionStrategy</code>
        /// used to pick which worker node to send a message</param>
        public static void UseDistributorFor <T>(this IServiceBusConfigurator configurator, IEndpointFactory endpointFactory,
                                                 IWorkerSelectionStrategy <T> workerSelectionStrategy)
            where T : class
        {
            configurator.AddService(() => new Distributor <T>(endpointFactory, workerSelectionStrategy));

            configurator.SetReceiveTimeout(50.Milliseconds());
        }
        /// <summary>
        /// Implements a distributor-to-worker pattern for the given message type.
        /// </summary>
        /// <typeparam name="TMessage">The type of to use the distributor</typeparam>
        /// <param name="configurator">Service bus to implement the distributor</param>
        /// <param name="workerSelectionStrategy">The <code>IWorkerSelectionStrategy</code>
        /// used to pick which worker node to send a message</param>
        public static void UseDistributorFor <TMessage>(this ServiceBusConfigurator configurator,
                                                        IWorkerSelectionStrategy <TMessage> workerSelectionStrategy)
            where TMessage : class
        {
            configurator.AddService(BusServiceLayer.Presentation, () => new Distributor <TMessage>(workerSelectionStrategy));

            configurator.SetReceiveTimeout(50.Milliseconds());
        }
示例#4
0
 public Distributor(IEndpointFactory endpointFactory, IWorkerSelectionStrategy <T> workerSelectionStrategy)
 {
     _endpointFactory   = endpointFactory;
     _selectionStrategy = workerSelectionStrategy;
 }