private static void RunMulticastErrorHandlingCase4() { EmptyQueues(); System.Console.Write("In the final example, we also delete the backup logging queue. Now the Routing Service will be unable to transactionally deliver the "); System.Console.Write("message to both a service queue and a backup queue, so it shouldn't move the message at all. At the end of this, we should see that "); System.Console.Write("because the Routing Service was unable to transactionally deliver the message to both a service queue and a logging queue, MSMQ marks "); System.Console.WriteLine("the message undeliverable. Based on our MSMQ settings, this should place it in the system Transactional DLQ. "); System.Console.WriteLine("Deleting the backup logging queue"); QueueUtils.DeleteQueue(backupLoggingPath); QueueUtils.InsertMessageIntoQueue("net.msmq://localhost/private/inQ"); System.Console.WriteLine("Press <Enter> to begin routing messages"); System.Console.ReadLine(); PrintQueueStatus(); }
private static void RunMulticastErrorHandlingCase3() { EmptyQueues(); System.Console.Write("In this example, we also delete the primary logging queue, forcing the Routing Service to send the message to both the backup "); System.Console.Write("service queue and the backup logging queue. Since both primary queues are unavailable, but the backup queues are present, we should "); System.Console.Write("see that the Routing Service is able to complete the transaction, successfully moving the message from the inbound queue to both the "); System.Console.WriteLine("backup service queue and the backup logging queue."); System.Console.WriteLine("Deleting the primary logging queue"); QueueUtils.DeleteQueue(primaryLoggingPath); QueueUtils.InsertMessageIntoQueue("net.msmq://localhost/private/inQ"); System.Console.WriteLine("Press <Enter> to begin routing messages"); System.Console.ReadLine(); PrintQueueStatus(); System.Console.WriteLine("Press <Enter> to continue"); System.Console.ReadLine(); }
private static void RunMulticastErrorHandlingCase2() { EmptyQueues(); System.Console.Write("In this example, we are going to delete the primary service queue, simulating a situation in which the system is unavailable "); System.Console.Write("for some reason. In this case, we should see one message show up in the backup service queue, and one message show up in the "); System.Console.Write("primary logging queue. This is beacuse the Routing Service is failing to contact the primary service queue (it doesn't exist), "); System.Console.Write("and so automatically fails that transaction and creates another to wrap the sends that occur to the backup service queue and the "); System.Console.Write("primary logging queue. Since the backup service queue and the primary logging queue both respond, the Routing Service is able "); System.Console.Write("to complete the transaction, successfully moving the message from the inbound queue to the backup service queue and the primary "); System.Console.WriteLine("logging queue"); System.Console.WriteLine("Deleting the primary service queue"); QueueUtils.DeleteQueue(primaryServicePath); QueueUtils.InsertMessageIntoQueue("net.msmq://localhost/private/inQ"); System.Console.WriteLine("Press <Enter> to begin routing messages"); System.Console.ReadLine(); PrintQueueStatus(); System.Console.WriteLine("Press <Enter> to continue"); System.Console.ReadLine(); }
//main method to run the four test cases static void Main(string[] args) { CreateAllQueues(); using (ServiceHost host = new ServiceHost(typeof(RoutingService))) { //uncomment this call and rename the provided App.config to something //else like App.config.example to run a Router configured via code //ConfigureRouterViaCode(host); host.Open(); System.Console.WriteLine("Routing Service Configured and Opened"); System.Console.WriteLine("Press Enter to Run Case 1"); System.Console.ReadLine(); RunMulticastErrorHandlingCase1(); } using (ServiceHost host = new ServiceHost(typeof(RoutingService))) { //uncomment this call and rename the provided App.config to something //else like App.config.example to run a Router configured via code //ConfigureRouterViaCode(host); host.Open(); System.Console.WriteLine("Press Enter to Run Case 2"); System.Console.ReadLine(); RunMulticastErrorHandlingCase2(); } using (ServiceHost host = new ServiceHost(typeof(RoutingService))) { //uncomment this call and rename the provided App.config to something //else like App.config.example to run a Router configured via code //ConfigureRouterViaCode(host); host.Open(); System.Console.WriteLine("Press Enter to Run Case 3"); System.Console.ReadLine(); RunMulticastErrorHandlingCase3(); } using (ServiceHost host = new ServiceHost(typeof(RoutingService))) { //uncomment this call and rename the provided App.config to something //else like App.config.example to run a Router configured via code //ConfigureRouterViaCode(host); host.Open(); System.Console.WriteLine("Press Enter to Run Case 4"); System.Console.ReadLine(); RunMulticastErrorHandlingCase4(); } System.Console.WriteLine("The System Dead Letter queue has {0} messages.", QueueUtils.GetMessageCount("FormatName:Direct=OS:.\\System$;DEADXACT")); System.Console.WriteLine("Press <Enter> to Quit"); System.Console.ReadLine(); EmptyQueues(); QueueUtils.DeleteQueue(Environment.MachineName + "\\private$\\backupServiceQueue"); QueueUtils.DeleteQueue(Environment.MachineName + "\\private$\\inQ"); }