In a message queue, can 2 consumers consume messages of the same type? In C.

Posted by Avi250@reddit | learnprogramming | View on Reddit | 10 comments

Hello, everyone; I have a server and multiple clients, who send their requests to the server. At one point, there could be another server (I'm calling them servers for a lack of a better word) to help the first server out. However, I need the consumers to be in a queue. I know it is agreed upon to have the messages' type be 1 and the server answers back with a message whose type is the client's pid. I also know message queues are destructive.

That said, can I have 2 servers consume type-1 messages? They'd have to race for them, which isn't a problem (at least not in my simulation: think restaurant or ticket offices). However, I need each message to be consumed, and only be consumed once. Even if it is possible, is it a practice that is frowned upon? If yes, why?

I'm writing this in C on linux, if it's necessary information.

Thank you in advance!