示例#1
0
        /// <summary>
        /// 获取消费配置
        /// </summary>
        /// <param name="name"></param>
        /// <returns></returns>
        public SubMsgConfig GetSubMsgConfig(string name)
        {
            if (string.IsNullOrEmpty(name))
            {
                throw new ArgumentNullException(nameof(name));
            }
            SubMsgConfig m = null;

            return(subMsgDic.TryGetValue(name, out m) ? m.Copy() : null);
        }
示例#2
0
        private void LoadSubMsg(XmlElement rootElement)
        {
            var nodes = rootElement.SelectNodes("SubMsg/Key");

            subMsgDic = new Dictionary <string, SubMsgConfig>(nodes.Count);
            foreach (XmlNode node in nodes)
            {
                if (node is XmlElement)
                {
                    XmlElement element = node as XmlElement;
                    string     s       = element.GetAttribute("name");
                    if (string.IsNullOrEmpty(s))
                    {
                        throw new ArgumentNullException("SubMsg config is null!");
                    }
                    if (subMsgDic.ContainsKey(s))
                    {
                        throw new ArgumentException($"SubMsg config ({s}) is repeat!");
                    }

                    var m = new SubMsgConfig()
                    {
                        Name = s
                    };
                    s = element.GetAttribute("queue");
                    if (string.IsNullOrEmpty(s))
                    {
                        throw new ArgumentNullException($"SubMsg ({s}) queue is null!");
                    }
                    m.Queue = s;

                    s = element.GetAttribute("isQueueParam");
                    if (!string.IsNullOrEmpty(s))
                    {
                        m.IsQueueParam = s.ToLower() == "true" || s == "1";
                    }

                    subMsgDic.Add(m.Name, m);
                }
            }
        }