Project Home
Project Home
Documents
Documents
Wiki
Wiki
Discussion Forums
Discussions
Project Information
Project Info
Forum Topic - Message Queue Issue: (1 Item)
   
Message Queue Issue  
Hi,

I have come across a problem in using message Queues.  

Requirement:
I need to reclaim a message queue descriptor which is become invalid while the program is being run [for e.g. server 
fails or restart].

Problem:
As per my design, server creates Message Queue, a server thread remain in receive blocked state which waits for any 
queue notification pulse and finally queue is unlinked during server termination. Client opens the Queue in read/write 
mode and save the descriptor as part of initialization step. Client uses this descriptor throughout its life to send any
 data to queue and the descriptor will be closed only during client Termination. So I want to recover the message queue 
descriptor when it becomes stale (i.e. server gets restarted). I used ha client recovery APIs for this purpose. But as 
per mq_unlink () documentation, 
‘If some process has the queue open when the call to mq_unlink () is made, then the actual deletion of the queue is 
postponed until it has been closed.’  So found that mq_send () API returns success even if the server has unlinked the 
queue, until client closes the already opened Message Queue descriptor. Recovery function is called only when mq_send ()
 returns bad descriptor error. But this error codes are generated only when client explicitly close all opened message 
Queue descriptor. But as per my design message queue descriptors will be closed only at client termination to avoid the 
message queue open/close calls overhead each time. How come I manage such situations? How can I recover message queue 
descriptor when the server terminates using HA Client Recovery Library or any other method? Can you please provide a 
general template followed in using message queues for IPC and its recovery mechanism?

Regards,
Princy