Exemplo n.º 1
0
 static void Move(IEnumerable<string> args)
 {
     var maximum = args.FirstNumberOr(1);
       var sourceQueue = args.NonIntegerArgs().Skip(1).First().ToQueueName();
       var destinyQueue = args.NonIntegerArgs().Last().ToQueueName();
       var source = new MessageQueue(sourceQueue, QueueAccessMode.SendAndReceive);
       var destiny = new MessageQueue(destinyQueue, QueueAccessMode.SendAndReceive);
       Console.WriteLine("Moving " + maximum + " messages from " + sourceQueue + " to " + destinyQueue);
       while (maximum > 0)
       {
     var message = source.FastReceive(MessageQueueTransactionType.Automatic);
     if (message == null)
     {
       Console.WriteLine("No more messages");
       break;
     }
     Console.WriteLine("Moving " + message.Id + " " + sourceQueue + " to " + destinyQueue);
     destiny.Send(message, MessageQueueTransactionType.Single);
     maximum--;
       }
 }