상속: IClusterMessageFormatter
예제 #1
0
 private Stream HackMessageAsRemote(DistributedLuceneActivity.LuceneActivityDistributor message)
 {
     var formatter = new BinaryMessageFormatter();
     var clusterMemberInfo = new ClusterMemberInfo();
     clusterMemberInfo.InstanceID = Guid.NewGuid().ToString();   // ensures message percieved as coming from other source
     message.SenderInfo = clusterMemberInfo;
     return formatter.Serialize(message);
 }
예제 #2
0
        public void Msmq_Receive()
        {
            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();
            }

            // send a single message to the receive queue and check if it gets received and executed
            var message = new TestAction();

            var clusterMemberInfo = new ClusterMemberInfo();
            clusterMemberInfo.InstanceID = Guid.NewGuid().ToString();   // ensures message percieved as coming from other source

            message.SenderInfo = clusterMemberInfo;
            Stream messageStream = new BinaryMessageFormatter().Serialize(message);
            var m = new System.Messaging.Message(messageStream);
            m.TimeToBeReceived = TimeSpan.FromSeconds(RepositoryConfiguration.MessageRetentionTime);
            m.Formatter = new System.Messaging.BinaryMessageFormatter();

            _messageReceivedEvent = new AutoResetEvent(false);
            msmq._receiveQueue.Send(m); // send message to receivequeue

            // test for execution: _messageReceived should be set to true
            var received = _messageReceivedEvent.WaitOne(3000);
            Assert.IsTrue(received, "Distributed action was not received/executed within 3 seconds");
        }
예제 #3
0
 private DistributedLuceneActivity.LuceneActivityDistributor CheckLucMessage(System.Messaging.Message recvmessage)
 {
     var formatter = new BinaryMessageFormatter();
     var lucmessage = formatter.Deserialize(recvmessage.Body as Stream) as DistributedLuceneActivity.LuceneActivityDistributor;
     var recactivity = lucmessage.Activity as TestLuceneActivity;
     Assert.IsTrue(recactivity != null, "Received message differs from message that was sent.");  // check if we received the message that we have sent
     return lucmessage;
 }
예제 #4
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.");
                }
            }

        }