MSMQ - Fast Maker / Slow Consumer

I have a messaging problem (with MSMQ), which is a kind of fast producer / slow consumer. Is there a way to get an outstanding number of unused messages in an MSMQ private queue? I would like to use this to throttle the manufacturer.

I would like to use the semaphore paradigm with MSMQ, where the producer application will send messages only if the number of remaining messages is less than the specified one.

Essentially, I would like to do something like the following

///Producer pseudo-code 
    public void SendMessage(Message message, int totalMessagesSentCounter)
    {
       if (totalMessagesSentCounter % 1000 == 0)
       {
         while (outgoingQueue.GetMessageCount() > X)  ///Is this possible?
         {
             Sleep(Y milliseconds);
         }
        }
       outgoingQueue.Send(Message);
       totalMessagesSentCounter++;
    }

My configuration: Win XP / 2003 with MSMQ 3.0

+3
source share
2 answers

MSMQ, , .

- .

"" , , . , , .

, "" , .

, , , , . , .

+2

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


All Articles