public void Run() { // Create an in-memory TransactionalTransport and point it to the AuditQ // Serialize data into the database. string auditQueue = ConfigurationManager.AppSettings["AuditQueue"]; string machineName = Environment.MachineName; // Make sure that the queue being monitored, exists! if (!MessageQueue.Exists(MsmqUtilities.GetFullPathWithoutPrefix(auditQueue))) { // The error queue being monitored must be local to this endpoint throw new Exception(string.Format("The audit queue {0} being monitored must be local to this endpoint and must exist. Make sure a transactional queue by the specified name exists. The audit queue to be monitored is specified in the app.config", auditQueue)); } // Create an in-memory transport with the same configuration as that of the current endpoint. AuditMessageQueueTransport = new TransactionalTransport() { IsTransactional = CurrentEndpointTransport.IsTransactional, MaxRetries = CurrentEndpointTransport.MaxRetries, IsolationLevel = CurrentEndpointTransport.IsolationLevel, MessageReceiver = new MsmqMessageReceiver(), NumberOfWorkerThreads = CurrentEndpointTransport.NumberOfWorkerThreads, TransactionTimeout = CurrentEndpointTransport.TransactionTimeout, FailureManager = CurrentEndpointTransport.FailureManager }; AuditMessageQueueTransport.Start(new Address(auditQueue, machineName)); AuditMessageQueueTransport.TransportMessageReceived += new EventHandler <TransportMessageReceivedEventArgs>(AuditMessageQueueTransport_TransportMessageReceived); }
public void Install(System.Security.Principal.WindowsIdentity identity) { var auditMessagesQueueName = ConfigurationManager.AppSettings["AuditQueue"]; Console.WriteLine("Checking to see if Audit Queue: {0} exists ...", auditMessagesQueueName); var auditMessagesQueuePath = MsmqUtilities.GetFullPathWithoutPrefix(auditMessagesQueueName); if (!MessageQueue.Exists(auditMessagesQueuePath)) { Console.WriteLine("Creating Audit Queue: {0}", ConfigurationManager.AppSettings["AuditQueue"]); MessageQueue.Create(auditMessagesQueuePath, true); } }
private static void DeletePluginQueue(string pluginInputQueue) { var fullName = MsmqUtilities.GetFullPathWithoutPrefix(pluginInputQueue); if (MessageQueue.Exists(fullName)) { MessageQueue.Delete(fullName); Console.WriteLine("Plugin queue {0} successfully removed", fullName); } else { Console.WriteLine("Could not find Plugin queue {0}", fullName); } }
private static void ClearSubscriptionStorage(string subscriptionStorageQueue, string pluginInputQueue) { var fullName = MsmqUtilities.GetFullPathWithoutPrefix(subscriptionStorageQueue); if (!MessageQueue.Exists(fullName)) { return; } var queue = new MessageQueue(fullName); foreach (var message in queue.GetAllMessages()) { if (message.Label.ToLower().Contains(pluginInputQueue.ToLower())) { queue.ReceiveById(message.Id); } } Console.WriteLine("SubscriptionStorage queue {0} successfully cleared", subscriptionStorageQueue); }