TPENQUEUE-routine to enqueue a message
01TPQUEDEF-REC.
COPY TPQUEDEF.
01TPTYPE-REC.
COPY TPTYPE.
01DATA-REC.
COPY User data.
01TPSTATUS-REC.
COPY TPSTATUS.
CALL "TPENQUEUE" USINGTPQUEDEF-RECTPTYPE-RECDATA-RECTPSTATUS-REC.
TPENQUEUE stores a message on the queue named by QNAME in the QSPACE-NAME queue space. A queue space is a collection of queues, one of which must be QNAME.
When the message is intended for a BEA TUXEDO system server, the QNAME matches the name of a service provided by a server. The system provided server, TMQFORWARD(5), provides a default mechanism for dequeuing messages from the queue and forwarding them to servers that provide a service matching the queue name. If the originator expected a reply, then the reply to the forwarded service request is stored on the originator's (stable) queue. The originator will dequeue the reply message at a subsequent time. Queues can also be used for a reliable message transfer mechanism between any pair of BEA TUXEDO system processes (clients and/or servers). In this case, the queue name does not match a service name but some agreed upon title for transferring the message.
The data portion of a message is specified by DATA-REC and LEN in TPTYPE-REC specifies how much of DATA-REC to enqueue. Note that if DATA-REC is a record of a type that does not require a length to be specified, then LEN is ignored (and may be 0). If REC-TYPE in TPTYPE-REC is SPACES, DATA-REC and LEN are ignored and a message is enqueued with no data portion. The REC-TYPE and SUB-TYPE, both in TPTYPE-REC, must match one of the REC-TYPEs and SUB-TYPEs recognized by QSPACE-NAME.
The message is queued at the priority defined for QSPACE-NAME unless overridden by a previous call to TPSPRIO().
If the caller is within a transaction and TPTRAN is set, the message is queued in transaction mode. This has the effect that if TPENQUEUE returns successfully and the caller's transaction is committed successfully, then the message is guaranteed to be available subsequent to the transaction completing. If the caller's transaction is rolled back either explicitly or as the result of a transaction timeout or some communication error, then the message will be deleted from the queue (that is, the placing of the message on the queue is also rolled back). It is not possible to enqueue then dequeue the same message within the same transaction.
The message is not queued in transaction mode if either the caller is not in transaction mode, or TPNOTRAN is set. In this case, the queued message is stored on the queue in a separate transaction. Once TPENQUEUE returns successfully, the submitted message is guaranteed to be available. If a communication error or a timeout occurs (either transaction or blocking timeout), the application will not know whether or not the message was successfully stored on the queue.
The order in which messages are placed on the queue is controlled by the application via TPQUEDEF-REC as described below; the default queue ordering is set when the queue is created.
Following is a list of valid settings in TPQUEDEF-REC.
TPNOTRAN
TPNOTRAN or TPTRAN must be set.
TPTRAN
TPNOTRAN or TPTRAN must be set.
TPNOBLOCK
TPNOBLOCK or TPBLOCK must be set.
TPBLOCK
TPBLOCK is specified and a blocking condition exists, the caller blocks until the condition subsides or a timeout occurs (either transaction or blocking timeout). Either TPNOBLOCK or TPBLOCK must be set.
TPNOTIME
TPNOTIME or TPTIME must be set.
TPTIME
TPNOTIME or TPTIME must be set.
TPSIGRSTRT
TPNOSIGRSTRT or TPSIGRSTRT must be set.
TPNOSIGRSTRT
TPNOSIGRSTRT or TPSIGRSTRT must be set.
Additional information about queuing the message can be specified via TPQUEDEF-REC. This information includes values to override the default queue ordering placing the message at the top of the queue or before an enqueued message; an absolute or relative time after which a queued message is made available; a correlation identifier that aids in correlating a reply or failure message with the queued message; the name of a queue to which a reply should be enqueued; and the name of a queue to which any failure message should be enqueued.
TPQUEDEF-REC is used by the application program to pass and retrieve information associated with enqueuing the message. Settings are used to indicate what elements in the record are valid.
On input to TPENQUEUE, the following elements may be set in TPQUEDEF-REC:
05 DEQ-TIME PIC S9(9) COMP-5.
05 PRIORITY PIC S9(9) COMP-5.
05 MSGID PIC X(32).
05 CORRID PIC X(32).
05 REPLYQUEUE PIC X(15).
05 FAILUREQUEUE PIC X(15).
05 APPL-RETURN-CODE PIC S9(9) COMP-5.
The following values indicate what values are set in the TPQUEDEF-REC.
TPQTOP
TPQDEFAULT to use default queue ordering. TPQTOP, TPQBEFOREMSGID, or TPQDEFAULT must be set.
TPQBEFOREMSGID
MSGID. This request may not be granted depending on whether or not the queue was configured to allow overriding the queue ordering. Set TPQDEFAULT to use default queue ordering. TPQTOP, TPQBEFOREMSGID, or TPQDEFAULT must be set.
TPQTIME-ABS
DEQ-TIME. DEQ-TIME is an absolute time value as generated by time() or mktime() (the number of seconds since 00:00:00 UTC, January 1, 1970). Set TPQNOTIME if neither an absolute or relative time value is set. TPQTIME-ABS, TPQTIME-REL, or TPQNOTIME must be set.
TPQTIME-REL
DEQ-TIME specifies the number of seconds to delay after the transaction completes before the submitted message should be available. Set TPQNOTIME if neither an absolute or relative time value is set. TPQTIME-ABS, TPQTIME-REL, or TPQNOTIME must be set.
TPQPRIORITY
PRIORITY. The priority must be in the range 1 to 100, inclusive. The higher the number, the higher the priority (that is, a message with a higher number is dequeued before a message with a lower number). Set TPQNOPRIORITY if a priority value is not available.
TPQCORRID
CORRID is available when a message is dequeued with TPDEQUEUE(). This identifier accompanies any reply or failure message that is queued such that an application can correlate a reply with a particular request. Set TPQNOCORRID if a correlation identifier is not available.
TPQREPLYQ
REPLYQUEUE is associated with the queued message. Any reply to the message will be queued to the named queue within the same queue space as the request message. Set TPQNOREPLYQ if a reply queue name is not available.
TPQFAILUREQ
FAILUREQUEUE is associated with the queued message. If a failure occurs when the enqueued message is subsequently dequeued, a failure message will go to the named queue within the same queue space as the original request message. Set TPQNOFAILUREQ if a failure queue name is not available.
Additionally, APPL-RETURN-CODE can be set with a user-return code. This value will be returned to the application that dequeues the message.
On output from TPENQUEUE, the following elements may be set in TPQUEDEF-REC:
05 MSGID PIC X(32).
05 DIAGNOSTIC PIC S9(9) COMP-5.
Following is a list of valid settings controlling output information from TPENQUEUE. If the setting is true when TPENQUEUE is called, the associated element in the record is populated if available and the setting remains true. If the value is not available, the setting will not be true after TPENQUEUE completes.
TPQMSGID
TPENQUEUE was successful, the message identifier will be stored in MSGID. TPQNOMSGID is set if a message identifier is not available.
If the call to TPENQUEUE failed and TP-STATUS is set to TPEDIAGNOSTIC, a value indicating the reason for failure is returned in DIAGNOSTIC. The possible values are defined below in the DIAGNOSTICS section.
Upon successful completion, TPENQUEUE sets TP-STATUS to [TPOK].
Under the following conditions, TPENQUEUE fails and sets TP-STATUS to the following values (unless otherwise noted, failure does not affect the caller's transaction, if one exists).
TPEINVAL]
QSPACE-NAME is SPACES or settings in TPQUEDEF-REC are invalid).
TPENOENT]
QSPACE-NAME because it is not available (the associated TMQUEUE(5) server is not available).
TPETIME]
TPBLOCK and TPTIME were specified. If a transaction timeout occurred, then any attempts to call TPDEQUEUE or TPENQUEUE will fail with TPETIME until the transaction has been aborted.
TPEBLOCK]
TPBLOCK was set.
TPGOTSIG]
TPNOSIGRSTRT was set.
TPEPROTO]
TPENQUEUE was called in an improper context. There is no effect on the queue or the transaction.
TPESYSTEM]
TPEOS]
TPEDIAGNOSTIC]
TPQUEDEF-REC.
The following diagnostic values are returned during the enqueuing of a message.
QMEINVAL]
QMEBADRMID]
QMENOTOPEN]
QMETRAN]
TPNOTRAN setting and an error occurred trying to start a transaction in which to enqueue the message.
QMEBADMSGID]
QMESYSTEM]
QMEOS]
QMEABORTED]
QMEPROTO]
QMEBADQUEUE]
QMENOSPACE]
TMQFORWARD(5), TMQUEUE(5), TPDEQUEUE(), TPSPRIO()