示例#1
0
        public void Msmq_Send()
        {
            var msmq = DistributedApplication.ClusterChannel as MsmqChannelProvider;

            // init: purge queues
            msmq._receiveQueue.Purge();
            for (var i = 0; i < msmq._sendQueues.Count; i++)
            {
                var sendqueue = msmq._sendQueues[i];
                sendqueue.Purge();
            }

            // distribute a single message, and check remote queues if message arrived
            var msg = new TestMessage();

            msg.Send();

            var formatter = new BinaryMessageFormatter();

            try
            {
                for (var i = 0; i < msmq._sendQueues.Count; i++)
                {
                    var sendqueue   = msmq._sendQueues[i];
                    var recvmsg     = sendqueue.Receive(TimeSpan.FromSeconds(3));
                    var recvtestmsg = formatter.Deserialize(recvmsg.Body as Stream) as TestMessage;
                    Assert.IsTrue(recvtestmsg.Message == msg.Message, "Received message differs from message that was sent.");  // check if we received the message that we have sent
                }
            }
            catch (System.Messaging.MessageQueueException mex)
            {
                if (mex.MessageQueueErrorCode == System.Messaging.MessageQueueErrorCode.IOTimeout)
                {
                    Assert.Fail("Receiving test message from remote queue timed out.");
                }
            }
        }
示例#2
0
        public void Msmq_Send()
        {
            var msmq = DistributedApplication.ClusterChannel as MsmqChannelProvider;

            // init: purge queues
            msmq._receiveQueue.Purge();
            for (var i = 0; i < msmq._sendQueues.Count; i++)
            {
                var sendqueue = msmq._sendQueues[i];
                sendqueue.Purge();
            }

            // distribute a single message, and check remote queues if message arrived
            var msg = new TestMessage();
            msg.Send();

            var formatter = new BinaryMessageFormatter();
            try
            {
                for (var i = 0; i < msmq._sendQueues.Count; i++)
                {
                    var sendqueue = msmq._sendQueues[i];
                    var recvmsg = sendqueue.Receive(TimeSpan.FromSeconds(3));
                    var recvtestmsg = formatter.Deserialize(recvmsg.Body as Stream) as TestMessage;
                    Assert.IsTrue(recvtestmsg.Message == msg.Message, "Received message differs from message that was sent.");  // check if we received the message that we have sent
                }
            }
            catch (System.Messaging.MessageQueueException mex)
            {
                if (mex.MessageQueueErrorCode == System.Messaging.MessageQueueErrorCode.IOTimeout)
                {
                    Assert.Fail("Receiving test message from remote queue timed out.");
                }
            }

        }