Пример #1
0
        public static void AddQueue(string name)
        {
            McQueueProperties prop = new McQueueProperties(name);
            McQueue           rq   = McQueue.Create(prop);

            QueueManager[mqp.QueueName] = rq;
        }
Пример #2
0
        private static void AddQueue(string name)
        {
            McQueueProperties mqp = new McQueueProperties(name);
            McQueue           rq  = McQueue.Create(mqp);

            _QueueHandler[mqp.QueueName] = rq;
        }
Пример #3
0
        private static void RunRemoteQueue()
        {
            McQueueProperties prop = new McQueueProperties("NC_Quick");

            //prop.ConnectionString = cnn;
            prop.CoverMode = CoverMode.FileSystem;//.ItemsAndLog;
            prop.Server    = 0;
            //prop.Provider = QueueProvider.SqlServer;
            prop.ReloadOnStart = true;
            Console.WriteLine("create remote queue");
            RemoteQueue rque = RemoteManager.Create(prop);

            //rque.ReceiveCompleted += new ReceiveCompletedEventHandler(rq_ReceiveCompleted);


            //RemoteQueue.AddQueue(prop);
            Console.WriteLine("rempote queue created");
            rque.MessageArraived += new QueueItemEventHandler(rq_MessageArraived);
            rque.MessageReceived += new QueueItemEventHandler(rq_MessageReceived);
            //Console.WriteLine(rqc.Reply("test"));

            //AsyncManagerWorker();
            RunThreads(new ThreadStart(AsyncRemoteDequeue), 10);
            RunThreads(new ThreadStart(AsyncManagerWorker), 10);

            while (true)
            {
                IAsyncResult result = rque.BeginReceive(null);
                Console.WriteLine("Count: {0}", rque.Count);
                Thread.Sleep(10);
            }
            Console.ReadLine();
        }
Пример #4
0
        internal static void LoadQueues()
        {
            if (!QueueLoaded)
            {
                System.Configuration.Configuration config =
                    ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);

                XmlDocument doc = new XmlDocument();
                doc.Load(config.FilePath);

                Console.WriteLine("Load Config: " + config.FilePath);

                XmlNode     root = doc.SelectSingleNode("//remoteSettings");
                XmlNodeList list = root.ChildNodes;

                for (int i = 0; i < list.Count; i++)
                {
                    //n.FirstChild.ChildNodes[1].InnerText
                    McQueueProperties prop =
                        new McQueueProperties(list[i]);
                    //prop.ConnectionString = ConnectionString;
                    //prop.Provider = Provider;
                    Console.WriteLine("Load: " + prop.QueueName);

                    RemoteQueueManager.AddQueue(prop);
                }
                QueueLoaded = true;
            }
        }
Пример #5
0
        internal static void AddQueue(McQueueProperties prop)
        {
            if (_QueueHandler.ContainsKey(prop.QueueName))
            {
                return;
            }

            McQueue rq = McQueue.Create(prop);

            _QueueHandler[prop.QueueName] = rq;
        }
Пример #6
0
        public McQueue AddQueue(McQueueProperties mqp)
        {
            if (_QueueHandler.ContainsKey(mqp.QueueName))
            {
                //throw new ArgumentException(aqt.QueueName + " allready exists");
                return(_QueueHandler[mqp.QueueName]);
            }

            McQueue rq = new McQueue(mqp);

            //rq.ErrorOcurred += new ErrorOcurredEventHandler(rq_ErrorOcurred);
            //rq.ReceiveCompleted += new QueueItemEventHandler(rq_ReceiveCompleted);
            _QueueHandler[mqp.QueueName] = rq;

            return(rq);
        }
Пример #7
0
        private static void RunAsyncQueue()
        {
            DateTime          start = DateTime.Now;
            McQueueProperties prop  = new McQueueProperties(qnmae);

            //prop.ConnectionString = cnn;
            prop.CoverMode = CoverMode.FileSystem;//.ItemsAndLog;
            prop.Server    = 0;
            //prop.Provider = QueueProvider.SqlServer;
            prop.IsTrans = true;
            McQueue queue = McQueue.Create(prop);

            //queue.ReceiveCompleted += new ReceiveCompletedEventHandler(q_DequeueCompleted);
            IQueueItem[] items = CreateItems(3, queue);

            int count = queue.Count;

            Console.WriteLine("start enqueue");

            //CreateItems(10,queue);

            count = queue.Count;
            int index = 0;

            Console.WriteLine("count:{0}", count);

            queue.Enqueue(items[0]);
            queue.Enqueue(items[1]);
            queue.Enqueue(items[2]);

            //IQueueItem item= queue.Dequeue();
            //queue.CommitTrans(item);


            while (true)//index < count)
            {
                queue.BeginReceive(null);
                //queue.BeginReceive(TimeSpan.FromSeconds(10.0), 0,
                //    new AsyncCallback(MsgReceiveCompleted));
                index++;
                Thread.Sleep(10);
            }
            TimeSpan ts = DateTime.Now.Subtract(start);

            Console.WriteLine("took:{0}", ts.TotalSeconds);
            //signal.WaitOne();
        }
Пример #8
0
        public static void RunAsyncQueue()
        {
            DateTime start = DateTime.Now;

            QueueClient client = new QueueClient();

            McQueueProperties prop = new McQueueProperties(qnmae);

            //prop.ConnectionString = cnn;
            //prop.CoverMode = CoverMode.ItemsAndLog;
            //prop.Server = 0;
            //prop.Provider = QueueProvider.SqlServer;
            //prop.IsTrans = true;
            queue = McQueue.Create(prop);
            //queue.ReceiveCompleted += new ReceiveCompletedEventHandler(q_DequeueCompleted);


            Console.WriteLine("start enqueue");
            QueueInserter.InsertItems(100, queue);
            int count = queue.Count;

            Console.WriteLine("count:{0}", count);

            QueueListner();


            int index = 0;


            while (true)//index < count)
            {
                queue.BeginReceive(null);
                //queue.BeginReceive(TimeSpan.FromSeconds(10.0), 0,
                //    new AsyncCallback(MsgReceiveCompleted));
                index++;
                Thread.Sleep(10);
            }
            TimeSpan ts = DateTime.Now.Subtract(start);

            Console.WriteLine("took:{0}", ts.TotalSeconds);
            //signal.WaitOne();
        }
Пример #9
0
        public void AddQueue(IDictionary prop)
        {
            McQueueProperties mqp = McQueueProperties.Create(prop);

            AddQueue(prop);
        }
Пример #10
0
        //=================== End Async Queue =====================================

        //=================== Queue =====================================

        //static RemoteQueue rq;
        //static IAsyncQueue queue;
        private static void RunQueueTest()
        {
            McQueueProperties prop = new McQueueProperties("Cellcom");

            //prop.ConnectionString = cnn;
            prop.CoverMode = CoverMode.FileSystem;//.ItemsAndLog;
            prop.Server    = 0;
            //prop.Provider = QueueProvider.SqlServer;

            RemoteQueue rq = new RemoteQueue(prop.QueueName);

            Console.WriteLine(rq.Reply("test"));

            IQueueItem[] items = CreateItems(3, rq);


            RemoteQueue rq2 = new RemoteQueue(prop.QueueName);//"Cellcom");//RemoteQueue.Instance;

            Console.WriteLine(rq2.Reply("test"));

            IQueueItem[] itemsb = CreateItems(3, rq);

            rq2.Enqueue(itemsb[0]);
            rq2.Enqueue(itemsb[1]);
            rq2.Enqueue(itemsb[2]);

            int count = rq2.Count;

            DataTable dt2 = rq.GetQueueItemsTable();

            count = dt2.Rows.Count;


            int countq = rq.Count;

            Console.WriteLine(countq.ToString());


            rq.Enqueue(items[0]);
            rq.Enqueue(items[1]);
            rq.Enqueue(items[2]);
            countq = rq.Count;
            Console.WriteLine(countq.ToString());

            //DataTable dt = McQueue.Queues.GetAllCoverItems();// GetAllItems();//QueueProvider.Embedded, null);
            //     string fileName = Environment.CurrentDirectory + "\\McQueue.xml";
            //    dt.WriteXml(fileName);


            Thread.Sleep(100);
            IQueueItem[] items2 = new IQueueItem[3];
            int          intout = 0;

            while (intout < 2)
            {
                IQueueItem it = rq.Dequeue();
                if (it != null)
                {
                    items2[intout] = it;
                }
                countq = rq.Count;
                Console.WriteLine(countq.ToString());
                Thread.Sleep(100);
            }
        }
Пример #11
0
 public static void AddQueue(McQueueProperties prop)
 {
     //McQueue rq = McQueue.Create(prop);
     //RemoteQueueServer.QueueManager[prop.QueueName] = rq;
     RemoteQueueServer.QueueManager.Create(prop, McLock.Lock.ValidateLock());
 }
Пример #12
0
 public void AddQueue(IDictionary prop)
 {
     AddQueue(McQueueProperties.Create(prop));
 }
Пример #13
0
        public static void AddQueue(McQueueProperties prop)
        {
            McQueue rq = McQueue.Create(prop);

            QueueManager[prop.QueueName] = rq;
        }