예제 #1
0
        private static void RecycleGuard()
        {
            while (Common.IsRun)
            {
                try
                {
                    //获取所有监控状态
                    List <MqCount> list = MSMQHelper.GetMqCount(_config);

                    if (list != null && list.Count > 0)
                    {
                        IStateCenterConnector connector = StateCenterConnectorFactory.GetAvailableConnector();
                        string msg = string.Empty;
                        foreach (MqCount mq in list)
                        {
                            msg += mq.Name + "@" + mq.Count + "@" + mq.Remark + "|";
                        }
                        connector.SendMsg("msmq", msg);
                    }
                }
                catch (Exception ex)
                {
                    CommonLog.InnerErrorLog.Error("mq监控出错:" + ex.ToString());
                }
                Thread.Sleep(Config.Internal);
            }
        }
예제 #2
0
        static void Main(string[] args)
        {
            switch (args[0])
            {
            case "mssend":
                if (args.Length > 2)
                {
                    TestSend(args[1], args[2]);
                }
                else
                {
                    TestSend(args[1]);
                }
                break;

            case "mscount":
                TestGetCount(args[1]);
                break;

            case "msallcount":
                TestAllCount();
                break;

            case "msconfig":

                var mqConfig = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "mq.config");
                if (File.Exists(mqConfig) == false)
                {
                    Console.WriteLine("找不到" + mqConfig);
                }
                else
                {
                    MSMQConfig msmqConfig = null;
                    msmqConfig = XmlHelper.Xml2Entity(mqConfig, new MSMQConfig().GetType()) as MSMQConfig;
                    List <MqCount> list = MSMQHelper.GetMqCount(msmqConfig);
                    foreach (MqCount mc in list)
                    {
                        Console.WriteLine(string.Format(" {0} | {1} | {2}", mc.Name, mc.Count, mc.Remark));
                    }
                }
                break;

            default:
                Console.WriteLine("nothing todo ");
                break;
            }
            Console.Read();
        }