private bool Match(string subscriberName, SubscriptionRule desc, Message message) { if (message == null || message.Header == null) { return(false); } RoutingRuleValidator v = RoutingRuleValidator.CreateRoutingRuleValidatorFromCache(desc); if (v == null) { _log.Write(LogType.Error, "[PushSenderAgent] Create routing rule validator failed for " + subscriberName); return(false); } if (v.Match(message)) { _log.Write("[PushSenderAgent] Message (type " + message.Header.Type + ") matched the subscription rule of " + subscriberName + ", route the message."); return(true); } else { if (v.LastError != null) { _log.Write(v.LastError); } _log.Write("[PushSenderAgent] Message (type " + message.Header.Type + ") does not matched the subscription rule of " + subscriberName + ", block the message."); return(false); } }
public PullChannelConfig FindTheFirstMatchedChannel(Message msg) { if (msg == null) { return(null); } foreach (PullChannelConfig chn in Channels) { RoutingRuleValidator v = RoutingRuleValidator.CreateRoutingRuleValidatorFromCache(chn.RequestContract); if (v != null && v.Match(msg)) { return(chn); } } return(null); }