private static void DemoMsmq() { // msmq processor var msmqProcessor = new MsmqProcessor<Sample>( MsmqUtility.GetQueue(@".\private$\queue"), MsmqUtility.GetQueue(@".\private$\errorQueue"), MsmqUtility.GetQueue(@".\private$\fatalQueue"), 4, TimeSpan.FromMilliseconds(100), new SampleReceiver() ); // start clean for demo MsmqUtility.PurgeAll(msmqProcessor.Queues); // send to queue msmqProcessor.Send(new SampleSender().GetItems()); // receive from queues msmqProcessor.Receive(); // send to queue msmqProcessor.Send(new SampleSender().GetItems()); // receive from queues msmqProcessor.Receive(); }
public void Test_NoEx() { var msmqProcessor = new MsmqProcessor<Sample>( queue, errorQueue, fatalQueue, 4, TimeSpan.FromMilliseconds(100), new SampleReceiver_NoEx() ); MsmqUtility.PurgeAll(msmqProcessor.Queues); Assert.AreEqual(0, queue.GetAllMessages().Length); Assert.AreEqual(0, errorQueue.GetAllMessages().Length); Assert.AreEqual(0, fatalQueue.GetAllMessages().Length); msmqProcessor.Send(new SampleSender().GetItems()); Assert.AreEqual(10, queue.GetAllMessages().Length); Assert.AreEqual(0, errorQueue.GetAllMessages().Length); Assert.AreEqual(0, fatalQueue.GetAllMessages().Length); msmqProcessor.Receive(); Assert.AreEqual(0, queue.GetAllMessages().Length); Assert.AreEqual(0, errorQueue.GetAllMessages().Length); Assert.AreEqual(0, fatalQueue.GetAllMessages().Length); }