lrt_tpdequeue

Communication Functions

Fetches a message from a queue.

int lrt_tpdequeue( char *qspace, char *qname, TPQCTL *ctl, char **data, long *len, long flags );

qspace Queue space.
qname Queue name.
ctl Message identifier (optional, by default the top message is fetched from the queue).
data Pointer to buffer into which a message is read.
len Length of the message.
flags Valid flags: TPNOTRAN- if caller is in transaction mode and this flag is set, the message is not fetched from the queue within the same transaction, TPNOCHANGE - buffer type of reply data is not allowed to change, TPNOBLOCK - request not sent if blocking condition exists, TPNOTIME - caller immune to blocking timeouts, TPSIGRSTRT - any interrupted system calls are re-issued after lrt_tpdequeue.

The lrt_tpdequeue function fetches a message for processing and removes if from a queue. By default, the message at the top of the queue is fetched. To request a specific message, specify the message identifier in ctl.

Return Values

If lrt_tpdequeue ends successfully, the application can obtain additional message information using the ctl structure. If the function ends with an error, it returns -1 and sets the error code in tperrno.

Parameterization

The following argument(s) can be parameterized using standard parameterization: qspace, qname

Example

In the following example data is put on a queue with an application defined user code, the code is read, and the message is taken off the queue.

Copy code
TPQCTL         qCtrl;     /* Control structure needed to reference item on queue */
                long         myAppcURCode;        /* Application defined return code */
                long         myRecovedURCode;    /* To read the UR Code */
                int         rc;             /* return code */
                char         * myQSpace;            /* Name of queue space */
                char         * myQName;             /* Name of queue */
                char         * myDataPtr;             /* The data */
                long         myDataLen;            /* Length */
                    myQSpace = "qspace";
                    myQName = "qname";
                    myDataPtr = lrt_tpalloc("STRING", "", 100);
                    strcpy(myDataPtr, "theData");
                    myAppcURCode = 100;
                    /* Put an application defined user code in the control structure */
                    qCtrl.urcode = myAppcURCode;
                    /* Put the data and control structure on a queue */
                    rc = lrt_tpenqueue( myQSpace, 
                                        myQName, 
                                        &qCtrl, 
                                        myDataPtr, 
                                        myDataLen, 
                                        TPNOTRAN); 
                    /* Recover the application defined user code */
                    myRecovedURCode = lrt_gettpurcode (); 
                    /* Take the message off the queue by using the same control structure */
                    rc =  lrt_tpdequeue( myQSpace, 
                                        myQName, 
                                        &qCtrl, 
                                        &myDataPtr, 
                                        &myDataLen, 
                            TPNOTRAN );