private void OnPulish(Message message) { message.Track("node publish message"); if (!SubscriberCenter.IsSubscribers(message.Consumers) && message.Mode == ReceiveMode.Eq) { ISubscriber subs = mLocalSubscriberCenter.Find(message.Consumers); if (subs != null) { subs.Process(this, message); return; } subs = mRemoteSubscriberCenter.Find(message.Consumers); if (subs != null) { subs.Process(this, message); return; } string error = string.Format("[{0}] subscriber not fount!", message.Consumers); message.ProcessError(new SRException(error)); Loger.Process(LogType.ERROR, error); } else { IList <ISubscriber> local, remote; local = mLocalSubscriberCenter.Find(message); remote = mRemoteSubscriberCenter.Find(message); if (local.Count == 0 && remote.Count == 0) { string error = string.Format("[{0}] subscriber not fount!", message.Consumers); message.ProcessError(new SRException(error)); Loger.Process(LogType.ERROR, error); return; } foreach (ISubscriber item in local) { Message sendMsg = message.Copy(); sendMsg.Consumers = item.Name; sendMsg.Mode = ReceiveMode.Eq; item.Process(this, sendMsg); } foreach (ISubscriber item in remote) { Message sendMsg = message.Copy(); sendMsg.Consumers = item.Name; sendMsg.Mode = ReceiveMode.Eq; item.Process(this, sendMsg); } } }
private void OnPulish(Message message) { message.Track("node publish message"); if (!SubscriberCenter.IsSubscribers(message.Consumers) && message.Mode == ReceiveMode.Eq) { message.Track("match consumers start"); ISubscriber subs = mLocalSubscriberCenter.Find(message.Consumers); message.Track("match consumers completed"); if (subs != null) { ProcessingMessage(); message.Track("publish to " + message.Consumers + subs.GetType()); subs.Process(this, message); message.Track("publish to " + message.Consumers + " completed!"); ProcessedMessage(); return; } subs = mRemoteSubscriberCenter.Find(message.Consumers); if (subs != null) { ProcessingMessage(); message.Track("publish to " + message.Consumers + subs.GetType()); subs.Process(this, message); message.Track("publish to " + message.Consumers + " completed!"); ProcessedMessage(); return; } string error = string.Format("[{0}] subscriber not fount!", message.Consumers); message.ProcessError(new SRException(error)); Loger.Process(LogType.ERROR, error); } else { IList <ISubscriber> local, remote; message.Track("match consumers start"); local = mLocalSubscriberCenter.Find(message); remote = mRemoteSubscriberCenter.Find(message); message.Track("match consumers completed"); if (local.Count == 0 && remote.Count == 0) { string error = string.Format("[{0}] subscriber not fount!", message.Consumers); message.ProcessError(new SRException(error)); Loger.Process(LogType.ERROR, error); return; } foreach (ISubscriber item in local) { if (message.Pulisher == item.Name) { continue; } ProcessingMessage(); Message sendMsg = message.Copy(); sendMsg.Consumers = item.Name; sendMsg.Mode = ReceiveMode.Eq; message.Track("publish to " + sendMsg.Consumers + item.GetType()); item.Process(this, sendMsg); ProcessedMessage(); message.Track("publish to " + sendMsg.Consumers + " completed!"); } foreach (ISubscriber item in remote) { ProcessingMessage(); Message sendMsg = message.Copy(); sendMsg.Consumers = item.Name; sendMsg.Mode = ReceiveMode.Eq; message.Track("publish to " + sendMsg.Consumers + item.GetType()); item.Process(this, sendMsg); message.Track("publish to " + sendMsg.Consumers + " completed!"); ProcessedMessage(); } } }
private void OnPulish(Message message) { message.Track("node publish message"); if (!SubscriberCenter.IsSubscribers(message.Consumers) && message.Mode == ReceiveMode.Eq) { message.Track("match consumers start"); ISubscriber subs = mLocalSubscriberCenter.Find(message.Consumers); message.Track("match consumers completed"); if (subs != null) { ProcessingMessage(); message.Track("publish to " + message.Consumers + subs.GetType()); subs.Process(this, message); message.Track("publish to " + message.Consumers + " completed!"); ProcessedMessage(); return; } subs = mRemoteSubscriberCenter.Find(message.Consumers); if (subs != null) { ProcessingMessage(); message.Track("publish to " + message.Consumers + subs.GetType()); subs.Process(this, message); message.Track("publish to " + message.Consumers + " completed!"); ProcessedMessage(); return; } string error = string.Format("[{0}] subscriber not fount!", message.Consumers); message.ProcessError(new SRException(error)); Loger.Process(LogType.ERROR, error); } else { SubscriberCenter.SearchResult localresult = null, remotresult = null; mLocalSubscriberCache.TryGetValue(message.Consumers, out localresult); mRemoteSubscriberCache.TryGetValue(message.Consumers, out remotresult); message.Track("match consumers start"); if (localresult == null || localresult.Version != mLocalSubscriberCenter.Version) { localresult = new SubscriberCenter.SearchResult(); localresult.Version = mLocalSubscriberCenter.Version; mLocalSubscriberCenter.Find(message, localresult.Items); mLocalSubscriberCache[message.Consumers] = localresult; } if (remotresult == null || remotresult.Version != mRemoteSubscriberCenter.Version) { remotresult = new SubscriberCenter.SearchResult(); remotresult.Version = mRemoteSubscriberCenter.Version; mRemoteSubscriberCenter.Find(message, remotresult.Items); mRemoteSubscriberCache[message.Consumers] = remotresult; } IList <ISubscriber> local = localresult.Items; IList <ISubscriber> remote = remotresult.Items; message.Track("match consumers completed"); if (local.Count == 0 && remote.Count == 0) { string error = string.Format("[{0}] subscriber not fount!", message.Consumers); message.ProcessError(new SRException(error)); Loger.Process(LogType.ERROR, error); return; } ISubscriber item; for (int i = 0; i < local.Count; i++) { item = local[i]; if (message.Pulisher == item.Name) { continue; } ProcessingMessage(); Message sendMsg = message.Copy(); sendMsg.Consumers = item.Name; sendMsg.Mode = ReceiveMode.Eq; message.Track("publish to " + sendMsg.Consumers + item.GetType()); item.Process(this, sendMsg); ProcessedMessage(); message.Track("publish to " + sendMsg.Consumers + " completed!"); } for (int i = 0; i < remote.Count; i++) { item = remote[i]; ProcessingMessage(); Message sendMsg = message.Copy(); sendMsg.Consumers = item.Name; sendMsg.Mode = ReceiveMode.Eq; message.Track("publish to " + sendMsg.Consumers + item.GetType()); item.Process(this, sendMsg); message.Track("publish to " + sendMsg.Consumers + " completed!"); ProcessedMessage(); } } }