We are in the process of replacing an internal implementation of a message queue (due to limitations of the overall design), and I'd like to use boost::interprocess::message_queue
as a nearly drop-in replacement.
However, we have a specific requirement that in the case that the message queue is "full" (the consuming application is either disconnected or lagging behind), that the "oldest" messages be discarded.
We can accomplish this easily like this:
do
{
if(sent = message_queue.try_send(...))
{
break;
}
else
{
message_queue.receive(...);
}
}
while(true);
However, I can't find reference in the documents that state this is safe. It's obviously not a traditional use of a message queue (to consume it from multiple applications), but is it guaranteed to work?