예제 #1
0
        private void SendNodeAnnouncement(string msg = null, string reply = null)
        {
            try
            {
                if (!this.NodeReady())
                {
                    Logger.Debug(Strings.SendNodeAnnouncementNotReadyDebugLogMessage, ServiceDescription());
                    return;
                }

                Logger.Debug(Strings.SendNodeAnnouncementDebugLogMessage, ServiceDescription(), reply != null ? reply : "everyone");

                DiscoverMessage discoverMessage = new DiscoverMessage();
                if (msg != null)
                {
                    discoverMessage.FromJsonIntermediateObject(JsonConvertibleObject.DeserializeFromJson(msg));
                }

                if (string.IsNullOrEmpty(discoverMessage.Plan) || discoverMessage.Plan == this.plan)
                {
                    Announcement a = this.AnnouncementDetails;
                    a.Id   = this.nodeId;
                    a.Plan = this.plan;
                    NodeNats.Publish(reply != null ? reply : string.Format(CultureInfo.InvariantCulture, Strings.NatsSubjectAnnounce, ServiceName()), null, a.SerializeToJson());
                }
            }
            catch (Exception ex)
            {
                Logger.Warning(ex.ToString());
            }
        }
예제 #2
0
        private void SendNodeAnnouncement(string msg = null, string reply = null)
        {
            try
            {
                if (!this.NodeReady())
                {
                    Logger.Debug(Strings.SendNodeAnnouncementNotReadyDebugLogMessage, ServiceDescription());
                    return;
                }

                Logger.Debug(Strings.SendNodeAnnouncementDebugLogMessage, ServiceDescription(), reply != null ? reply : "everyone");

                DiscoverMessage discoverMessage = new DiscoverMessage();
                if (msg != null)
                {
                    discoverMessage.FromJsonIntermediateObject(JsonConvertibleObject.DeserializeFromJson(msg));
                }

                if (string.IsNullOrEmpty(discoverMessage.Plan) || discoverMessage.Plan == this.plan)
                {
                    Announcement a = this.AnnouncementDetails;
                    a.Id = this.nodeId;
                    a.Plan = this.plan;
                    a.SupportedVersions = this.supportedVersions.ToArray();
                    nodeNats.Publish(reply != null ? reply : string.Format(CultureInfo.InvariantCulture, Strings.NatsSubjectAnnounce, ServiceName()), null, a.SerializeToJson());
                }
            }
            catch (Exception ex)
            {
                Logger.Warning(ex.ToString());
            }
        }