public void Lesson(IActivateHandlers activateHandlers)
        {
            var handlers = activateHandlers.GetHandlerInstancesFor <RebusHierarchyLesson>();

            IHandleMessages <RebusHierarchyLesson> firstHandler = handlers.First();

            firstHandler.Handle(new RebusHierarchyLesson());
        }
        public void Lesson(IActivateHandlers activateHandlers)
        {
            var handlers = activateHandlers.GetHandlerInstancesFor<RebusHierarchyLesson>();

            IHandleMessages<RebusHierarchyLesson> firstHandler = handlers.First();

            firstHandler.Handle(new RebusHierarchyLesson());
        }
            public IEnumerable <IHandleMessages <T> > GetHandlerInstancesFor <T>()
            {
                var handlerInstancesToReturn = innerActivator
                                               .GetHandlerInstancesFor <T>()
                                               .ToList();

                // if there's no correlation ID in the header, just return
                var currentHeaders = MessageContext.GetCurrent().Headers;

                if (!currentHeaders.ContainsKey(Headers.CorrelationId))
                {
                    return(handlerInstancesToReturn);
                }

                // if there's no registered callback for this correlationID/type, just return
                var correlationId = currentHeaders[Headers.CorrelationId].ToString();
                var key           = GetKey(correlationId, typeof(T));

                if (!registeredReplyHandlers.ContainsKey(key))
                {
                    return(handlerInstancesToReturn);
                }

                // if we don't succeed in retrieving the callback (unlikely!), just return
                ReplyCallback replyCallback;

                if (!registeredReplyHandlers.TryRemove(key, out replyCallback))
                {
                    return(handlerInstancesToReturn);
                }

                // otherwise, we may add our special callback handler
                log.Info("Adding in-mem callback handler for {0}", replyCallback.Callback);
                handlerInstancesToReturn.Add(new ReplyMessageHandler <T>(replyCallback, correlationId));

                return(handlerInstancesToReturn);
            }
Exemplo n.º 4
0
 public IEnumerable <IHandleMessages <T> > GetHandlerInstancesFor <T>()
 {
     return(handlerActivator.GetHandlerInstancesFor <T>());
 }