2011-11-21 113 views
6

我在更改提交給定義的MSMQ的消息的優先級時遇到問題。 每當我設置消息優先它似乎永遠不會到隊列 這裏內影響消息的優先級是我在做什麼snipet:如何更改MSMQ中消息的優先級?

static public void QueueBatchItem(MessageQueue mq, MessageQueueTransaction msgTx, MessagePriority msgPriority) 
{ 
    using (System.Messaging.Message mm = new System.Messaging.Message()) 
    { 
     string messageLabel = Guid.NewGuid().ToString(); 
     System.Messaging.XmlMessageFormatter formatter = new XmlMessageFormatter(); 

     RunSimulationRequestDTO dto = new RunSimulationRequestDTO(); 
     dto.RetryCount = 0; 
     dto.BatchHeaderID = batchID; 
     dto.MSMQLabel = messageLabel; 

     mq.MessageReadPropertyFilter.Priority = true; 
     mm.Priority = msgPriority; 

     mm.Body = dto; 
     mm.Label = messageLabel; 
     mm.Formatter = formatter; 
     mq.Send(mm, msgTx); 

    } 
} 

如果我調試通代碼中的默認優先級爲「正常'當一個項目被髮送到隊列時,優先級顯示爲'Queue messages'爲0。我可以將優先級作爲MessagePriority.High或8個可能的值中的任何一個來傳遞,並且它永遠不會改變優先級。

我缺少的是在這...這是我見過的幾個例子都顯示事情已經基本爲

Message mm = new Message(); 
mm.Priority = MessagePriority.High; 

我甚至嘗試了一些測試應用程序的我主要的代碼與外MSDN示例和優先級編號從不改變。

謝謝。

編輯: 我確信,我所看到的優先權不是從線程來將其設置爲AboveNormal

<ThreadManagersConfiguration DefaultSleepBetweenPolls="5000" DefaultMsmqServer="."> 
    <ThreadManagers> 
     <add DisplayName="BatchSimulationManager" 
      RequestMSMQ=".\Private$\BatchSimulationRequest" 
      ResponseMSMQ="" 
      FailedMSMQ=".\Private$\BatchSimulationFailure" 
      Priority="AboveNormal" 
      TransactionalMode="RollbackTransaction" 
      MaxThreads="16" 
      SleepTimeBetweenPolling="10000" 
      ProcessModel="BATCH"/> 
    </ThreadManagers> 
    </ThreadManagersConfiguration> 

queue

+0

這是一個專用於您的應用程序的隊列嗎? – iandotkelly

+0

是的,這是一個私人隊列。 –

+0

您一定在查看消息優先級,而不是隊列優先級,默認值爲0 – iandotkelly

回答