/// <summary>
        /// Adds a message handler to the service bus for handling a specific type of message
        /// </summary>
        /// <typeparam name="T">The message type to handle, often inferred from the callback specified</typeparam>
        /// <param name="bus"></param>
        /// <param name="handler">The callback to invoke when messages of the specified type arrive on the service bus</param>
        public static UnsubscribeAction SubscribeHandlerSelector <T>(this IServiceBus bus, HandlerSelector <T> handler)
            where T : class
        {
            var connector = new HandlerSubscriptionConnector <T>();

            return(bus.Configure(x => connector.Connect(x, handler)));
        }
Пример #2
0
        public HandlerSubscriptionBuilder(HandlerSelector <TMessage> handler,
                                          Func <UnsubscribeAction, ISubscriptionReference> referenceFactory)
        {
            _handler          = handler;
            _referenceFactory = referenceFactory;

            _connector = new HandlerSubscriptionConnector <TMessage>();
        }
Пример #3
0
        public HandlerSubscriptionBuilder(HandlerSelector <TMessage> handler,
                                          ReferenceFactory referenceFactory)
        {
            _handler          = handler;
            _referenceFactory = referenceFactory;

            _connector = new HandlerSubscriptionConnector <TMessage>();
        }
Пример #4
0
        public static UnsubscribeAction ConnectHandler <TMessage>(this IInboundMessagePipeline pipeline,
                                                                  Action <TMessage> handler,
                                                                  Predicate <TMessage> condition)
            where TMessage : class
        {
            return(pipeline.Configure(x =>
            {
                var connector = new HandlerSubscriptionConnector <TMessage>();

                return connector.Connect(x, HandlerSelector.ForSelectiveHandler(condition, handler));
            }));
        }