ReturnAll() public method

public ReturnAll ( ) : void
return void
コード例 #1
0
        public override void MoveAllErrorMessagesToOriginQueue(string errorQueue)
        {
            var mgr = new ErrorManager();

            try {
                if (errorQueue != null)
                {
                    mgr.InputQueue = Address.Parse(errorQueue);

                    mgr.ReturnAll();
                }
                else // Return All Error Queues

                {
                    foreach (var queue in MonitorQueues.Where(q => q.Type == QueueType.Error))
                    {
                        mgr.InputQueue = Address.Parse(errorQueue = queue.Name);

                        mgr.ReturnAll();
                    }
                }
            } catch (Exception e) {
                throw new Exception("Failed to Move Messages from Error Queue '{0}' to Origin".With(errorQueue), e);
            }
        }
コード例 #2
0
        static void Main(string[] args)
        {
            var errorManager = new ErrorManager();

            string inputQueue = null;
            string messageId  = null;

            if (args != null && args.Length > 0)
            {
                inputQueue = args[0];
            }

            if (args != null && args.Length > 1)
            {
                messageId = args[1];
            }

            if (inputQueue == null)
            {
                Console.WriteLine("Please enter the error queue you would like to use:");
                inputQueue = Console.ReadLine();
            }

            if (messageId == null)
            {
                Console.WriteLine("Please enter the id of the message you'd like to return to its source queue, or 'all' to do so for all messages in the queue.");
                messageId = Console.ReadLine();

                Console.WriteLine("Attempting to return message to source queue. Please stand by.");
            }

            errorManager.InputQueue = Address.Parse(inputQueue);

            try
            {
                if (messageId == "all")
                {
                    errorManager.ReturnAll();
                }
                else
                {
                    errorManager.ReturnMessageToSourceQueue(messageId);
                }

                if (args == null || args.Length == 0)
                {
                    Console.WriteLine("Press 'Enter' to exit.");
                    Console.ReadLine();
                }
            }
            catch (Exception e)
            {
                Console.WriteLine("Could not return message to source queue. Reason: " + e.Message);
                Console.WriteLine(e.StackTrace);

                Console.WriteLine("\nPress 'Enter' to exit.");
                Console.ReadLine();
            }
        }
コード例 #3
0
    public override void MoveAllErrorMessagesToOriginQueue(string errorQueue) {
      var mgr = new ErrorManager();

      // TODO:
      // Check if Clustered Queue, due if Clustered && NonTransactional, then Error

      mgr.InputQueue = Address.Parse(errorQueue);

      mgr.ReturnAll();
    }
コード例 #4
0
    static void Main(string[] args)
    {
        var errorManager = new ErrorManager();

        string inputQueue = null;
        string messageId  = null;

        if (args != null && args.Length > 0)
        {
            inputQueue = args[0];
        }

        if (args != null && args.Length > 1)
        {
            messageId = args[1];
        }

        var script = true;

        if (inputQueue == null)
        {
            Console.WriteLine("NServiceBus ReturnToSource for MSMQ");
            Console.WriteLine("by Particular Software Ltd. \n");

            Console.WriteLine("Please enter the error queue you would like to use:");
            inputQueue = Console.ReadLine();
            if (string.IsNullOrWhiteSpace(inputQueue))
            {
                Console.WriteLine("No error queue specified");
                Console.WriteLine("\nPress 'Enter' to exit.");
                Console.ReadLine();
                return;
            }
            script = false;
        }

        var errorQueueAddress = MsmqAddress.Parse(inputQueue);

        if (!IsLocalIpAddress(errorQueueAddress.Machine))
        {
            Console.WriteLine("Input queue [{0}] resides on a remote machine: [{1}].", errorQueueAddress.Queue, errorQueueAddress.Machine);
            Console.WriteLine("Due to networking load, it is advised to refrain from using ReturnToSourceQueue on a remote error queue, unless the error queue resides on a clustered machine.");
            if (!script)
            {
                Console.WriteLine(
                    "Press 'y' if the error queue resides on a Clustered Machine, otherwise press any key to exit.");
                if (Console.ReadKey().Key.ToString().ToLower() != "y")
                {
                    return;
                }
            }
            Console.WriteLine(string.Empty);
            errorManager.ClusteredQueue = true;
        }

        if (messageId == null)
        {
            Console.WriteLine("Please enter the id of the message you'd like to return to its source queue, or 'all' to do so for all messages in the queue.");
            messageId = Console.ReadLine();
        }

        errorManager.InputQueue = errorQueueAddress;
        Console.WriteLine("Attempting to return message to source queue. Queue: [{0}], message id: [{1}]. Please stand by.",
                          errorQueueAddress, messageId);

        try
        {
            if (messageId == "all")
            {
                errorManager.ReturnAll();
            }
            else
            {
                errorManager.ReturnMessageToSourceQueue(messageId);
            }

            if (args == null || args.Length == 0)
            {
                Console.WriteLine("Press 'Enter' to exit.");
                Console.ReadLine();
            }
        }
        catch (Exception e)
        {
            Console.WriteLine("Could not return message to source queue. Reason: " + e.Message);
            Console.WriteLine(e.StackTrace);

            Console.WriteLine("\nPress 'Enter' to exit.");
            Console.ReadLine();
        }
    }
コード例 #5
0
    static void Main(string[] args)
    {
        var errorManager = new ErrorManager();

        string inputQueue = null;
        string messageId = null;

        if (args != null && args.Length > 0)
            inputQueue = args[0];

        if (args != null && args.Length > 1)
            messageId = args[1];

        var script = true;

        if (inputQueue == null)
        {
            Console.WriteLine("NServiceBus ReturnToSource for MSMQ");
            Console.WriteLine("by Particular Software Ltd. \n");

            Console.WriteLine("Please enter the error queue you would like to use:");
            inputQueue = Console.ReadLine();
            if (string.IsNullOrWhiteSpace(inputQueue))
            {
                Console.WriteLine("No error queue specified");
                Console.WriteLine("\nPress 'Enter' to exit.");
                Console.ReadLine();
                return;
            }
            script = false;
        }

        var errorQueueAddress = MsmqAddress.Parse(inputQueue);

        if (!IsLocalIpAddress(errorQueueAddress.Machine))
        {
            Console.WriteLine("Input queue [{0}] resides on a remote machine: [{1}].", errorQueueAddress.Queue, errorQueueAddress.Machine);
            Console.WriteLine("Due to networking load, it is advised to refrain from using ReturnToSourceQueue on a remote error queue, unless the error queue resides on a clustered machine.");
            if (!script)
            {
                Console.WriteLine(
                    "Press 'y' if the error queue resides on a Clustered Machine, otherwise press any key to exit.");
                if (Console.ReadKey().Key.ToString().ToLower() != "y")
                    return;
            }
            Console.WriteLine(string.Empty);
            errorManager.ClusteredQueue = true;
        }

        if (messageId == null)
        {
            Console.WriteLine("Please enter the id of the message you'd like to return to its source queue, or 'all' to do so for all messages in the queue.");
            messageId = Console.ReadLine();
        }

        errorManager.InputQueue = errorQueueAddress;
        Console.WriteLine("Attempting to return message to source queue. Queue: [{0}], message id: [{1}]. Please stand by.",
            errorQueueAddress, messageId);

        try
        {
            if (messageId == "all")
                errorManager.ReturnAll();
            else
                errorManager.ReturnMessageToSourceQueue(messageId);

            if (args == null || args.Length == 0)
            {
                Console.WriteLine("Press 'Enter' to exit.");
                Console.ReadLine();
            }
        }
        catch (Exception e)
        {
            Console.WriteLine("Could not return message to source queue. Reason: " + e.Message);
            Console.WriteLine(e.StackTrace);

            Console.WriteLine("\nPress 'Enter' to exit.");
            Console.ReadLine();
        }
    }