2010-12-14 14 views

cevap

11

NServiceBus ile birlikte gelen ReturnToSourceQueue.exe numaralı basit bir komut satırı aracını kullanabilirsiniz.

Bu, tools klasörü IIRC klasöründe bulunur.

+0

Bu derlemeleri yansıtırsanız, bu işlemi çevreleyen ek araçların nasıl yapılacağını anlamak oldukça kolaydır; bu nedenle, her zaman sunucuda oturum açmanız ve bir komut satırı aracını çalıştırmanız gerekmez. –

4
private const string QUEUE_NAME = "private$\\localqueue"; 
    private const string ERROR_QUEUE_NAME = "private$\\localerrorqueue"; 

      if (!MessageQueue.Exists(".\\" + QUEUE_NAME)) 
       return; 

      if (!MessageQueue.Exists(".\\" + ERROR_QUEUE_NAME)) 
       return; 

      var messageQueues = MessageQueue.GetPrivateQueuesByMachine(Environment.MachineName); 

      var queue = messageQueues.Single(x => x.QueueName == QUEUE_NAME); 
      var errorQueue = messageQueues.Single(x => x.QueueName == ERROR_QUEUE_NAME); 

      var noOfErrorMessages = errorQueue.GetAllMessages().Count(); 

      if (noOfErrorMessages == 0) 
       return; 

      using (var transaction = new MessageQueueTransaction()) 
      { 
       transaction.Begin(); 

       for (var i = 0; i < noOfErrorMessages; i++) 
       { 
        var message = errorQueue.Receive(transaction); 
        queue.Send(message, transaction); 
       } 

       transaction.Commit(); 
      } 
İlgili konular