示例#1
0
        protected void InitReceiver(string agentName, string busName)
        {
            _MQAgent = MSMQAgent.GetMSMQAgent(agentName, busName);

            if (_MQAgent == null || _MQAgent.GetQueue() == null)
            {
                throw new Exception("Init receiver failed.");
            }

            if (_MQAgent.GetQueue() == null)
            {
                throw new Exception("Init receiver's queue failed.");
            }
        }
示例#2
0
        public bool StartReceiver()
        {
            //mq.CreateMQ();
            MessageQueue myQueue = null;
            bool         result  = false;

            try
            {
                myQueue = _MQAgent.GetQueue();
                if (myQueue == null)
                {
                    return(result);
                }
                //异步
                myQueue.PeekCompleted += new PeekCompletedEventHandler(PeekCompleted);
                myQueue.BeginPeek();
                result = true;
            }
            catch { }
            finally { }
            return(result);
        }