public virtual void Distribute()
        {
            var distributor = new LuceneActivityDistributor()
            {
                Activity = this
            };

            distributor.Execute();
            DistributedLuceneActivity.WriteMSMQLog(this, MSMQLogStatusType.SENT);
        }
        private static void WriteMSMQLog(DistributedLuceneActivity activity, MSMQLogStatusType statusType)
        {
            if (!MSMQLogEnabled)
                return;

            var pAct = activity as LuceneIndexingActivity;
            if (pAct == null)
                return;

            WriteMSMQLog(pAct.ActivityId, statusType, null);
        }
            public override void DoAction(bool onRemote, bool isFromMe)
            {
                if (!LuceneManager.Running)
                {
                    return;
                }

                //Trace.WriteLine(String.Format("@#$> T:{0} LuceneActivityDistributor.DoAction: {1}. onRemote: {2}, isFromMe:{3}", System.Threading.Thread.CurrentThread.ManagedThreadId, Activity.GetType().Name, onRemote, isFromMe));

                if (onRemote && !isFromMe)
                {
                    DistributedLuceneActivity.WriteMSMQLog(this.Activity, MSMQLogStatusType.RECEIVED);
                    this.Activity.InternalExecute();
                }
            }
        private static void WriteMSMQLog(DistributedLuceneActivity activity, MSMQLogStatusType statusType)
        {
            if (!MSMQLogEnabled)
            {
                return;
            }

            var pAct = activity as LuceneIndexingActivity;

            if (pAct == null)
            {
                return;
            }

            WriteMSMQLog(pAct.ActivityId, statusType, null);
        }
Esempio n. 5
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);
 }
Esempio n. 6
0
        private void TestIndexDocumentSending(DistributedLuceneActivity sendmsg)
        {
            // purge queues
            var msmq = DistributedApplication.ClusterChannel as MsmqChannelProvider;
            msmq._receiveQueue.Purge();
            for (var i = 0; i < msmq._sendQueues.Count; i++)
            {
                var sendqueue = msmq._sendQueues[i];
                sendqueue.Purge();
            }

            // distribute message
            sendmsg.Distribute();

            // grab message from send queue
            System.Messaging.Message recvmessage = null;
            try
            {
                recvmessage = msmq._sendQueues[0].Receive(TimeSpan.FromSeconds(3));
            }
            catch (System.Messaging.MessageQueueException mex)
            {
                if (mex.MessageQueueErrorCode == System.Messaging.MessageQueueErrorCode.IOTimeout)
                {
                    Assert.Fail("Receiving test message from remote queue timed out.");
                }
            }

            // check if message received is the one we have sent
            var lucmessage = CheckLucMessage(recvmessage);

            // simulate receiving/processing by calling OnMessageReceived
            _activityProcessedEvent = new AutoResetEvent(false);
            var remotedMessageStream = HackMessageAsRemote(lucmessage);
            msmq.OnMessageReceived(remotedMessageStream);

            // wait for message to be processed
            var processed = _activityProcessedEvent.WaitOne(3000);
            Assert.IsTrue(processed, "Lucene activity was not processed within 3 seconds");
        }