예제 #1
0
 public TopicRoute(ITopicRule rule, WriterCollection <IMessageSerializer> writers, ITopicRouter router,
                   IMessagingRoot root, MessageTypeRouting messageTypeRouting)
 {
     _rule               = rule;
     _writers            = writers;
     _router             = router;
     _root               = root;
     _messageTypeRouting = messageTypeRouting;
 }
예제 #2
0
        public StaticRoute(ISendingAgent agent,
                           WriterCollection <IMessageSerializer> writers, MessageTypeRouting routing)
        {
            _agent    = agent;
            _endpoint = agent.Endpoint;
            _writers  = writers;
            _routing  = routing;
            // TODO -- select the right serializer for the endpoint
            // hard-coding to JSON for now

            _writer = writers.ChooseWriter("application/json");
        }
예제 #3
0
        public override void AddRoute(MessageTypeRouting routing, IMessagingRoot root)
        {
            var messageType = routing.MessageType;
            var rule        = TopicRules.FirstOrDefault(x => x.Matches(messageType));

            if (rule == null)
            {
                var topicName = DetermineTopicName(messageType);
                var uri       = BuildUriForTopic(topicName);
                var agent     = root.Runtime.GetOrBuildSendingAgent(uri);
                agent.Endpoint.AddRoute(routing, root);
            }
            else
            {
                routing.AddTopicRoute(rule, this);
            }
        }
예제 #4
0
        public MessageTypeRouting RouteByType(Type messageType)
        {
            var routing = new MessageTypeRouting(messageType, _root);

            var subscribers = _root.Runtime
                              .FindSubscribersForMessageType(messageType);


            if (subscribers.Any())
            {
                foreach (var subscriber in subscribers)
                {
                    subscriber.AddRoute(routing, _root);
                }
            }
            else if (_root.Options.HandlerGraph.CanHandle(messageType))
            {
                routing.UseLocalQueueAsRoute();
            }

            return(routing);
        }
예제 #5
0
 public abstract void AddRoute(MessageTypeRouting routing, IMessagingRoot root);