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
public void SendMessage(Message message, int totalMessagesSentCounter)
{
if (totalMessagesSentCounter % 1000 == 0)
{
while (outgoingQueue.GetMessageCount() > X)
{
Sleep(Y milliseconds);
}
}
outgoingQueue.Send(Message);
totalMessagesSentCounter++;
}
My configuration: Win XP / 2003 with MSMQ 3.0
source
share