How to change message priority in MSMQ?

I have a problem with changing the priority of a message that is passed to a specific MSMQ. Whenever I set the priority of a message, it never affects the priority of a message in the queue Here is a snake of what I'm doing:

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); } } 

If I debug the code, the default priority is "Normal", and when the item is sent to the queue, the priority is displayed as "0" from the "Queue Message". I can pass priority as MessagePriority.High or any of the 8 possible values ​​and never changes the priority.

What I am missing in this ... a few examples that I saw showed that everything has basic concepts, like

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

I even tried only small test applications outside of my main code with MSDN examples and the priority number never changed.

thanks.

edit: I made sure that the priority I saw did not come from the thread by setting it to 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

+6
source share

Source: https://habr.com/ru/post/902007/


All Articles