Beispiel #1
0
        /// <summary>
        /// 获取Queue在XML文件的配置
        /// </summary>
        /// <param name="configFile"></param>
        /// <returns></returns>
        private static List <SubscribeHost> GetSubscribeHost(string configFile)
        {
            if (!File.Exists(configFile))
            {
                Log.Write(string.Format("未找到queue的配置文件:Path:{0}", configFile), MessageType.Warn);
                return(null);
            }

            var inputString = FileHelper.FileToString(configFile);
            var xmlHelper   = new XmlHelper(inputString);
            var qnode       = xmlHelper.GetNode("Queues");

            if (qnode == null)
            {
                Log.Write(string.Format("配置文件格式错误:Path:{0}", configFile), MessageType.Warn);
                return(null);
            }
            var queueNodes = qnode.ChildNodes;
            var hosts      = new List <SubscribeHost>();

            foreach (XmlNode queueNode in queueNodes)
            {
                var node = new SubscribeHost
                {
                    Host      = xmlHelper.GetValue(queueNode, "Host"),
                    QueueName = xmlHelper.GetValue(queueNode, "QueueName"),
                };
                hosts.Add(node);
            }
            return(hosts);
        }
Beispiel #2
0
 /// <summary>
 /// 需要消费Event
 /// </summary>
 /// <param name="host">队列配置对象</param>
 /// <param name="configurator"></param>
 public void SubscribeAt(SubscribeHost host, IConsumeConfigurator configurator)
 {
     if (host == null)
     {
         throw new ArgumentNullException("host");
     }
     SubscribeAt(host.Host, host.QueueName, host.CunsumerNum, configurator);
 }
Beispiel #3
0
        /// <summary>
        /// 获取Queue根据数据库读取的配置
        /// </summary>
        /// <param name="serverQueueConfig"></param>
        /// <returns></returns>
        private static List <SubscribeHost> GetSubscribeHost(List <ServerQueueConfig> serverQueueConfig)
        {
            var hosts = new List <SubscribeHost>();

            foreach (var queueConfig in serverQueueConfig)
            {
                var node = new SubscribeHost
                {
                    Host      = queueConfig.Host,
                    QueueName = queueConfig.QueueName,
                };
                hosts.Add(node);
            }
            return(hosts);
        }