multiple mail queues

Hi there…

Would somebody know how can i get multiple
processes read from the same mqueue, without
competing for the messages, i.e. every process
reads every message… I can notify them, but if
I read the message, it erases it. Do I have to
read with open and not mq_receive???

Thanx,

caco


Sent via Deja.com http://www.deja.com/
Before you buy.

cacolino@my-deja.com wrote:


Hi there…

Would somebody know how can i get multiple
processes read from the same mqueue, without
competing for the messages, i.e. every process
reads every message… I can notify them, but if
I read the message, it erases it. Do I have to
read with open and not mq_receive???

I don’t think it can be done – a message queue is similar
to a pipe, except the contents have a message size, rather
than just being a stream of bytes. This means that reading
a message removes it from the queue. It is not intended as
a one-to-many (broadcast) type message passing solution.

(How would the server know when to remove the message from the
queue?)

If you are running QNX4, there is a queueing server and library
available in source form from:

ftp.qnx.com:/usr/free/qnx4/os/samples/misc/queue.tgz

Since you have it in source form, you could implement the
multiple read capability that you are looking for.

Probably have a non-destructive read, and a “remove this message”
type read or something similar – you’d have to decide how to
implement this yourself. (Or, maybe maintain a count of readers
in the server, and keep different read positions for each reader,
and delete a message when everyone has read it.)

-David