コード例 #1
0
 private void InitLinks(NetMQContext ctx, ConcurrentDictionary <string, Link> links, QueueLinks queue, ZmqSocketType socketType)
 {
     foreach (LinkAddress sa in queue.Links)
     {
         log.InfoFormat("Connecting to {0}({1})", sa.Name, sa.Address);
         Link link = new Link
         {
             service = sa.Name,
             address = sa.Address,
             context = ctx,
             socket  = ctx.CreateSocket(socketType),
         };
         link.socket.Options.Identity = Encoding.UTF8.GetBytes(Guid.NewGuid().ToString());
         link.Connect();
         links[sa.Name] = link;
     }
 }
コード例 #2
0
ファイル: ServiceConfig.cs プロジェクト: icprog/FS-SMISCloud
        public static ServiceConfig FromXml(string file)
        {
            ServiceConfig sc = new ServiceConfig();

            try
            {
                log.InfoFormat("Parsing '{0}' ...", file);
                XDocument doc    = XDocument.Load(file);
                var       root   = doc.Root;
                var       psNode = root.Element("ps");
                if (psNode != null)
                {
                    var PubSub = new QueueLinks();
                    sc.PubSub = PubSub;
                    var pubNode = psNode.Element("publisher");
                    PubSub.ListenAddress = pubNode.Attribute("address").Value;
                    foreach (var node in psNode.Element("subscribe").Elements())
                    {
                        XAttribute addAttr = node.Attribute("address");
                        PubSub.Links.Add(new LinkAddress {
                            Name = node.Attribute("name").Value, Address = addAttr != null ? addAttr.Value : null
                        });
                    }
                }
                var ppNode = root.Element("pp");
                if (ppNode != null)
                {
                    var pp = new QueueLinks();
                    sc.PushPull = pp;
                    var pullNode = ppNode.Element("pull");
                    pp.ListenAddress = pullNode.Attribute("address").Value;
                    foreach (var node in ppNode.Element("push").Elements())
                    {
                        XAttribute addAttr = node.Attribute("address");
                        pp.Links.Add(new LinkAddress {
                            Name = node.Attribute("name").Value, Address = addAttr != null ? addAttr.Value : null
                        });
                    }
                }

                var pairNode = root.Element("rr");
                if (pairNode != null)
                {
                    var rr = new QueueLinks();
                    sc.ReqRep = rr;
                    var repNode = pairNode.Element("response");
                    rr.ListenAddress = repNode.Attribute("address").Value;
                    foreach (var node in pairNode.Element("request").Elements())
                    {
                        XAttribute addAttr = node.Attribute("address");
                        rr.Links.Add(new LinkAddress {
                            Name = node.Attribute("name").Value, Address = addAttr != null ? addAttr.Value : null
                        });
                    }
                }

                var settingNode = root.Element("settings");
                if (settingNode != null)
                {
                    var settingsNodes = root.Element("settings").Elements();
                    foreach (var node in settingsNodes)
                    {
                        sc.Properties.Add(node.Attribute("key").Value, node.Attribute("value").Value);
                    }
                }
            }
            catch (Exception e)
            {
                log.Error(e);
            }
            return(sc);
        }