Table of Contents Previous Next PDF


Oracle Tuxedo Message Queue Function Reference

Oracle Tuxedo Message Queue
Function Reference
 
Cancels all pending tpqgetmsga requests that match the value specified in the sel_filter argument.
Gets the errno of OTMQ system call.
tpdequeue()
Name
tpdequeue()—Routine to dequeue a message from a queue.
Synopsis
#include <atmi.h>
#include <tmqentry.h>
#include <tmqreturn.h>
int tpdequeue(char *qspace, char *qname, TPQCTL *ctl, char **data, long *len, long flags)
Description
tpdequeue() takes a message for processing from the queue named by qname in the qspace queue space.
By default, the message at the top of the queue is dequeued. The order of messages on the queue is defined when the queue is created. The application can request a particular message for dequeuing by specifying its message identifier or correlation identifier using the ctl parameter. ctl flags can also be used to indicate that the application wants to wait for a message, in the case when a message is not currently available. It is possible to use the ctl parameter to look at a message without removing it from the queue or changing its relative position on the queue. See the section below describing this parameter.
data is the address of a pointer to the buffer into which a message is read, and len points to the length of that message. *data must point to a buffer originally allocated by tpalloc(). If a message is larger than the buffer passed to tpdequeue, the buffer is increased in size to accommodate the message. To determine whether a message buffer changed in size, compare its (total) size before tpdequeue() was issued with *len. If *len is larger, then the buffer has grown; otherwise, the buffer has not changed size. Note that *data may change for reasons other than the buffer’s size increased. If *len is 0 upon return, then the message dequeued has no data portion and neither *data nor the buffer it points to were modified. It is an error for *data or len to be NULL.
The message is dequeued in transaction mode if the caller is in transaction mode and the TPNOTRAN flag is not set. This has the effect that if tpdequeue() returns successfully and the caller’s transaction is committed successfully, then the message is removed from the queue. 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 left on the queue (that is, the removal of the message from the queue is also rolled back). It is not possible to enqueue and dequeue the same message within the same transaction.
The message is not dequeued in transaction mode if either the caller is not in transaction mode, or the TPNOTRAN flag is set. When not in transaction mode, if a communication error or a timeout occurs, the application will not know whether or not the message was successfully dequeued and the message may be lost.
The following is a list of valid flags:
TPNOTRAN
If the caller is in transaction mode and this flag is set, the message is not dequeued within the caller’s transaction. A caller in transaction mode that sets this flag is still subject to the transaction timeout (and no other) when dequeuing the message. If message dequeuing fails, the caller’s transaction is not affected.
TPNOBLOCK
The message is not dequeued if a blocking condition exists. If this flag is set and a blocking condition exists such as the internal buffers into which the message is transferred are full, the call fails and tperrno is set to TPEBLOCK. If this flag is set and a blocking condition exists because the target queue is opened exclusively by another application, the call fails, tperrno is set to TPEDIAGNOSTIC, and the diagnostic field of the TPQCTL structure is set to QMESHARE. In the latter case, the other application, which is based on a Oracle product other than the Oracle Tuxedo ATMI system, opened the queue for exclusive read and/or write using the Queuing Services API (QSAPI).
When TPNOBLOCK is not set and a blocking condition exists, the caller blocks until the condition subsides or a timeout occurs (either transaction or blocking timeout). This blocking condition does not include blocking on the queue itself if the TPQWAIT option in flags (of the TPQCTL structure) is specified.
TPNOTIME
Setting this flag signifies that the caller is willing to block indefinitely and wants to be immune to blocking timeouts. Transaction timeouts may still occur.
TPNOCHANGE
When this flag is set, the type of the buffer pointed to by *data is not allowed to change. By default, if a buffer is received that differs in type from the buffer pointed to by *data, then *data’s buffer type changes to the received buffer’s type so long as the receiver recognizes the incoming buffer type. That is, the type and subtype of the dequeued message must match the type and subtype of the buffer pointed to by *data.
TPSIGRSTRT
Setting this flag indicates that any underlying system calls that are interrupted by a signal should be reissued. When this flag is not set and a signal interrupts a system call, the call fails and sets tperrno to TPGOTSIG.
If tpdequeue() returns successfully, the application can retrieve additional information about the message using the ctl data structure. The information may include the message identifier for the dequeued message; a correlation identifier that should accompany any reply or failure message so that the originator can correlate the message with the original request; the quality of service the message was delivered with, the quality of service any replies to the message should be delivered with; the name of a reply queue if a reply is desired; and the name of the failure queue on which the application can queue information regarding failure to dequeue the message. These are described below.
In a multithreaded application, a thread in the TPINVALIDCONTEXT state is not allowed to issue a call to tpdequeue().
Control Parameter
The TPQCTL structure is used by the application program to pass and retrieve parameters associated with dequeuing the message. The flags element of TPQCTL is used to indicate what other elements in the structure are valid.
On input to tpdequeue(), the following elements may be set in the TPQCTL structure:
long flags; /* indicates which of the values
* are set */
char msgid[32]; /* ID of message to dequeue */
char corrid[32]; /* correlation identifier of
* message to dequeue */
The following is a list of valid bits for the flags parameter controlling input information for tpdequeue():
TPNOFLAGS
No flags are set. No information is taken from the control structure.
TPQGETBYMSGID
Setting this flag requests that the message with the message identifier specified by ctl−>msgid be dequeued. The message identifier may be acquired by a prior call to tpenqueue(). Note that a message identifier changes if the message has moved from one queue to another. Note also that the entire 32 bytes of the message identifier value are significant, so the value specified by ctl−>msgid must be completely initialized (for example, padded with NULL characters).
TPQGETBYCORRID
Setting this flag requests that the message with the correlation identifier specified by ctl−>corrid be dequeued. The correlation identifier is specified by the application when enqueuing the message with tpenqueue(). Note that the entire 32 bytes of the correlation identifier value are significant, so the value specified by ctl−>corrid must be completely initialized (for example, padded with NULL characters).
TPQWAIT
Setting this flag indicates that an error should not be returned if the queue is empty. Instead, the process should wait until a message is available. If TPQWAIT is set in conjunction with TPQGETBYMSGID or TPQGETBYCORRID, it indicates that an error should not be returned if no message with the specified message identifier or correlation identifier is present in the queue. Instead, the process should wait until a message meeting the criteria is available. The process is still subject to the caller’s transaction timeout, or, when not in transaction mode, the process is subject to the timeout specified on the TMQUEUE process by the -t option.
If a message matching the desired criteria is not immediately available and the configured action resources are exhausted, tpdequeue()returns ‑1, tperrno is set to TPEDIAGNOSTIC, and the diagnostic field of the TPQCTL structure is set to QMESYSTEM.
Note that each tpdequeue() request specifying the TPQWAIT control parameter requires that a queue manager (TMQUEUE) action object be available if a message satisfying the condition is not immediately available. If an action object is not available, the tpdequeue() request fails. The number of available queue manager actions are specified when a queue space is created or modified. When a waiting dequeue request completes, the associated action object associated is made available for another request.
TPQPEEK
If this flag is set, the specified message is read but is not removed from the queue. This flag implies the TPNOTRAN flag has been set for the tpdequeue() operation. That is, non-destructive dequeuing is non-transactional. Note that it is not possible to read messages enqueued or dequeued within a transaction before the transaction completes.
When a thread is non-destructively dequeuing a message using TPQPEEK, the message may not be seen by other non-blocking dequeuers for the brief time the system is processing the non-destructive dequeue request. This includes dequeuers using specific selection criteria (such as message identifier and correlation identifier) that are looking for the message currently being non-destructively dequeued.
On output from tpdequeue(), the following elements may be set in the TPQCTL structure:
long flags; /* indicates which of the values
* should be set */

long priority; /* enqueue priority */
char msgid[32]; /* ID of message dequeued */
char corrid[32]; /* correlation identifier used to
* identify the message */
long delivery_qos; /* delivery quality of service */
long reply_qos; /* reply message quality of service */
char replyqueue[16]; /* queue name for reply */
char failurequeue[16]; /* queue name for failure */
long diagnostic; /* reason for failure */
long appkey; /* application authentication client
* key */
long urcode; /* user-return code */
CLIENTID cltid; /* client identifier for originating
* client */
The following is a list of valid bits for the flags parameter controlling output information from tpdequeue(). For any of these bits, if the flag bit is turned on when tpdequeue() is called, the associated element in the structure is populated with the value provided when the message was queued, and the bit remains set. If a value is not available or the bit is not set when tpdequeue() is called, tpdequeue() completes with the flag turned off.
TPQPRIORITY
If this flag is set, the call to tpdequeue() is successful, and the message was queued with an explicit priority, then the priority is stored in ctl−>priority. The priority is in the range 1 to 100, inclusive, and 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). For queues not ordered by priority, the value is informational.
If no priority was explicitly specified when the message was queued and the call to tpdequeue() is successful, the priority for the message is 50.
TPQMSGID
If this flag is set and the call to tpdequeue() is successful, the message identifier is stored in ctl−>msgid. The entire 32 bytes of the message identifier value are significant.
TPQCORRID
If this flag is set, the call to tpdequeue() is successful, and the message was queued with a correlation identifier, then the correlation identifier is stored in ctl−>corrid. The entire 32 bytes of the correlation identifier value are significant. Any Oracle Tuxedo ATMI /Q provided reply to a message has the correlation identifier of the original request message.
TPQDELIVERYQOS
If this flag is set, the call to tpdequeue() is successful, and the message was queued with a delivery quality of service, then the flag—TPQQOSDEFAULTPERSIST, TPQQOSPERSISTENT, or TPQQOSNONPERSISTENT—is stored in ctl‑>delivery_qos. If no delivery quality of service was explicitly specified when the message was queued, the default delivery policy of the target queue dictates the delivery quality of service for the message.
TPQREPLYQOS
If this flag is set, the call to tpdequeue() is successful, and the message was queued with a reply quality of service, then the flag—TPQQOSDEFAULTPERSIST, TPQQOSPERSISTENT, or TPQQOSNONPERSISTENT—is stored in ctl‑>reply_qos. If no reply quality of service was explicitly specified when the message was queued, the default delivery policy of the ctl‑>replyqueue queue dictates the delivery quality of service for any reply.
Note that the default delivery policy is determined when the reply to a message is enqueued. That is, if the default delivery policy of the reply queue is modified between the time that the original message is enqueued and the reply to the message is enqueued, the policy used is the one in effect when the reply is finally enqueued.
TPQREPLYQ
If this flag is set, the call to tpdequeue() is successful, and the message was queued with a reply queue, then the name of the reply queue is stored in ctl−>replyqueue. Any reply to the message should go to the named reply queue within the same queue space as the request message.
TPQFAILUREQ
If this flag is set, the call to tpdequeue() is successful, and the message was queued with a failure queue, then the name of the failure queue is stored in ctl−>failurequeue. Any failure message should go to the named failure queue within the same queue space as the request message.
The following remaining bits for the flags parameter are cleared (set to zero) when tpdequeue() is called: TPQTOP, TPQBEFOREMSGID, TPQTIME_ABS, TPQTIME_REL, TPQEXPTIME_ABS, TPQEXPTIME_REL, and TPQEXPTIME_NONE. These bits are valid bits for the flags parameter controlling input information for tpenqueue().
If the call to tpdequeue() failed and tperrno is set to TPEDIAGNOSTIC, a value indicating the reason for failure is returned in ctl−>diagnostic. The possible values are defined below in the Diagnostics section.
Additionally on output, if the call to tpdequeue() is successful, ctl−>appkey is set to the application authentication key, ctl−>cltid is set to the identifier for the client originating the request, and ctl−>urcode is set to the user-return code value that was set when the message was enqueued.
If the ctl parameter is NULL, the input flags are considered to be TPNOFLAGS, and no output information is made available to the application program.
Return Values
Upon failure, tpdequeue() returns -1 and sets tperrno to indicate the error condition.
Errors
Upon failure, tpdequeue() sets tperrno to one of the following values. (Unless otherwise noted, failure does not affect the caller’s transaction, if one exists.)
[TPEINVAL]
Invalid arguments were given (for example, qname is NULL, data does not point to space allocated with tpalloc() or flags are invalid).
[TPENOENT]
Cannot access the qspace because it is not available (that is, the associated TuxMsgQ server is not available), or cannot start a global transaction due to the lack of entries in the Global Transaction Table (GTT).
[TPEOTYPE]
Either the type and subtype of the dequeued message are not known to the caller; or, TPNOCHANGE was set in flags and the type and subtype of *data do not match the type and subtype of the dequeued message. In either case, *data, its contents, and *len are not changed. When the call is made in transaction mode and this error occurs, the transaction is marked abort-only, and the message remains on the queue.
[TPETIME]
This error code indicates that either a timeout has occurred or tpdequeue() has been attempted, in spite of the fact that the current transaction is already marked rollback only.
If the caller is in transaction mode, then either the transaction is already rollback only or a transaction timeout has occurred. The transaction is marked abort-only. If the caller is not in transaction mode, a blocking timeout has occurred. (A blocking timeout cannot occur if TPNOBLOCK and/or TPNOTIME is specified.) In either case, no changes are made to *data, its contents, or *len.
If a transaction timeout has occurred, then, with one exception, any attempts to perform further conversational work, send new requests, or receive outstanding replies will fail with TPETIME until the transaction has been aborted. The exception is a request that does not block, expects no reply, and is not sent on behalf of the caller’s transaction (that is, tpacall() with TPNOTRAN, TPNOBLOCK, and TPNOREPLY set).
When a service fails inside a transaction, the transaction is put into the TX_ROLLBACK_ONLY state. This state is treated, for most purposes, as though it were equivalent to a timeout. All further ATMI calls for this transaction (with the exception of those issued in the circumstances described in the previous paragraph) will fail with TPETIME.
[TPEBLOCK]
A blocking condition exists and TPNOBLOCK was specified.
[TPGOTSIG]
A signal was received and TPSIGRSTRT was not specified.
[TPEPROTO]
tpdequeue() was called improperly. There is no effect on the queue or the transaction.
[TPESYSTEM]
An Oracle Tuxedo system error has occurred. The exact nature of the error is written to a log file. There is no effect on the queue.
[TPEOS]
An operating system error has occurred. There is no effect on the queue.
[TPEDIAGNOSTIC]
Dequeuing a message from the specified queue failed. The reason for failure can be determined by the diagnostic value returned via ctl structure.
Diagnostic
The following diagnostic values are returned during the dequeuing of a message:
[QMEINVAL]
An invalid flag value was specified.
[QMEBADRMID]
An invalid resource manager identifier was specified.
[QMENOTOPEN]
The resource manager is not currently open.
[QMETRAN]
The call was not in transaction mode or was made with the TPNOTRAN flag set and an error occurred trying to start a transaction in which to dequeue the message. This diagnostic is not returned by queue managers from Oracle Tuxedo release 7.1 or later.
[QMEBADMSGID]
An invalid message identifier was specified for dequeuing.
[QMESYSTEM]
A system error has occurred. The exact nature of the error is written to a log file.
[QMEOS]
An operating system error has occurred.
[QMEABORTED]
The operation was aborted. When executed within a global transaction, the global transaction has been marked rollback-only. Otherwise, the queue manager aborted the operation.
[QMEPROTO]
A dequeue was done when the transaction state was not active.
[QMEBADQUEUE]
An invalid or deleted queue name was specified.
[QMENOMSG]
No message was available for dequeuing. Note that it is possible that the message exists on the queue and another application process has read the message from the queue. In this case, the message may be put back on the queue if that other process rolls back the transaction.
[QMEINUSE]
When dequeuing a message by message identifier or correlation identifier, the specified message is in use by another transaction. Otherwise, all messages currently on the queue are in use by other transactions. This diagnostic is not returned by queue managers from Oracle Tuxedo release 7.1 or later.
[QMESHARE]
When dequeuing a message from a specified queue, the specified queue is opened exclusively by another application. The other application is one based on an Oracle product other than the Oracle Tuxedo system that opened the queue for exclusive read and/or write using the Queuing Services API (QSAPI).
See Also
qmadmin(1), tpalloc(3c), tpenqueue(), APPQ_MIB(5), TMQUEUE(5)
tpenqueue()
Name
tpenqueue()—Routine to enqueue a message.
Synopsis
#include <atmi.h>
#include <tmqentry.h>
#include <tmqreturn.h>
int tpenqueue(char *qspace, char *qname, TPQCTL *ctl, char *data, long len, long flags)
Description
tpenqueue() stores a message on the queue named by qname in the qspace queue space. A queue space is a collection of queues, one of which must be qname.
When the message is intended for an Oracle Tuxedo ATMI system server, the qname matches the name of a service provided by the server. The system provided server, TMQFORWARDPLUS, 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 expects a reply, then the reply to the forwarded service request is stored on the originator’s queue, unless otherwise specified. 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 Oracle Tuxedo ATMI system processes (clients and/or servers). In this case, the queue name does not match a service name but some agreed upon name for transferring the message.
If data is non-NULL, it must point to a buffer previously allocated by tpalloc() and len should specify the amount of data in the buffer that should be queued. Note that if data points to a buffer of a type that does not require a length to be specified (for example, an FML fielded buffer), then len is ignored. If data is NULL, len is ignored and a message is queued with no data portion.
The message is queued at the priority defined for qspace unless overridden by a previous call to tpsprio().
If the caller is within a transaction and the TPNOTRAN flag is not 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 removed 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 the TPNOTRAN flag is set. Once tpenqueue() returns successfully, the submitted message is guaranteed to be in the queue. When not in transaction mode, if a communication error or a timeout occurs, 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 ctl data structure as described below; the default queue ordering is set when the queue is created.
The following is a list of valid flags:
TPNOTRAN
If the caller is in transaction mode and this flag is set, the message is not queued within the caller’s transaction. A caller in transaction mode that sets this flag is still subject to the transaction timeout (and no other) when queuing the message. If message queuing fails, the caller’s transaction is not affected.
TPNOBLOCK
The message is not enqueued if a blocking condition exists. If this flag is set and a blocking condition exists such as the internal buffers into which the message is transferred are full, the call fails and tperrno is set to TPEBLOCK. If this flag is set and a blocking condition exists because the target queue is opened exclusively by another application, the call fails, tperrno is set to TPEDIAGNOSTIC, and the diagnostic field of the TPQCTL structure is set to QMESHARE. In the latter case, the other application, which is based on an Oracle product other than the Oracle Tuxedo ATMI system, opened the queue for exclusive read and/or write using the Queuing Services API (QSAPI).
When TPNOBLOCK is not set and a blocking condition exists, the caller blocks until the condition subsides or a timeout occurs (either transaction or blocking timeout). If a timeout occurs, the call fails and tperrno is set to TPETIME.
TPNOTIME
Setting this flag signifies that the caller is willing to block indefinitely and wants to be immune to blocking timeouts. Transaction timeouts may still occur.
TPSIGRSTRT
If this flag is set and a signal interrupts any underlying system calls, the interrupted system call is reissued. If TPSIGRSTRT is not set and a signal interrupts a system call, tpenqueue() fails and tperrno is set to TPGOTSIG.
Additional information about queuing the message can be specified via ctl data structure. 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; an absolute or relative time when a message expires and is removed from the queue; the quality of service for delivering the message; the quality of service that any replies to the message should use; 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.
In a multithreaded application, a thread in the TPINVALIDCONTEXT state is not allowed to issue a call to tpenqueue().
Control Parameter
The TPQCTL structure is used by the application program to pass and retrieve parameters associated with enqueuing the message. The flags element of TPQCTL is used to indicate what other elements in the structure are valid.
On input to tpenqueue(), the following elements may be set in the TPQCTL structure:
long flags; /* indicates which of the values
* are set */
long deq_time; /* absolute/relative for dequeuing */
long priority; /* enqueue priority */
long exp_time /* expiration time */
long delivery_qos /* delivery quality of service */
long reply_qos /* reply quality of service */
long urcode; /* user-return code */
char msgid[32]; /* ID of message before which to queue
* request */
char corrid[32]; /* correlation identifier used to
* identify the msg */
char replyqueue[16]; /* queue name for reply message */
char failurequeue[16]; /* queue name for failure message */
The following is a list of valid bits for the flags parameter controlling input information for tpenqueue():
TPNOFLAGS
No flags or values are set. No information is taken from the control structure.
TPQTOP
Setting this flag indicates that the queue ordering be overridden and the message placed at the top of the queue. This request may not be granted depending on whether or not the queue was configured to allow overriding the queue ordering. TPQTOP and TPQBEFOREMSGID are mutually exclusive flags.
TPQBEFOREMSGID
Setting this flag indicates that the queue ordering be overridden and the message placed in the queue before the message identified by ctl−>msgid. This request may not be granted depending on whether or not the queue was configured to allow overriding the queue ordering. TPQTOP and TPQBEFOREMSGID are mutually exclusive flags. Note that the entire 32 bytes of the message identifier value are significant, so the value identified by ctl−>msgid must be completely initialized (for example, padded with NULL characters).
TPQTIME_ABS
If this flag is set, the message is made available after the time specified by ctl−>deq_time. The deq_time is an absolute time value as generated by time(2), mktime(3), or gp_mktime(3c) (the number of seconds since 00:00:00 Universal Coordinated Time—UTC, January 1, 1970). TPQTIME_ABS and TPQTIME_REL are mutually exclusive flags. The absolute time is determined by the clock on the machine where the queue manager process resides.
TPQTIME_REL
If this flag is set, the message is made available after a time relative to the completion of the enqueuing operation. ctl−>deq_time specifies the number of seconds to delay after the enqueuing completes before the submitted message should be available. TPQTIME_ABS and TPQTIME_REL are mutually exclusive flags.
TPQPRIORITY
If this flag is set, the priority at which the message should be enqueued is stored in ctl−>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). For queues not ordered by priority, this value is informational.
If this flag is not set, the priority for the message is 50 by default.
TPQCORRID
If this flag is set, the correlation identifier value specified in ctl−>corrid is available when a message is dequeued with tpdequeue(). This identifier accompanies any reply or failure message that is queued so that an application can correlate a reply with a particular request. Note that the entire 32 bytes of the correlation identifier value are significant, so the value specified in ctl−>corrid must be completely initialized (for example, padded with NULL characters).
TPQREPLYQ
If this flag is set, a reply queue named in ctl−>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. This string must be NULL terminated (maximum 15 characters in length).
TPQFAILUREQ
If this flag is set, a failure queue named in the ctl−>failurequeue is associated with the queued message. If (1) the enqueued message is processed by TMQFORWARD(), (2) TMQFORWARD was started with the -d option, and (3) the service fails and returns a non-NULL reply, a failure message consisting of the reply and its associated tpurcode is enqueued to the named queue within the same queue space as the original request message. This string must be NULL-terminated (maximum 15 characters in length).
TPQDELIVERYQOS, TPQREPLYQOS
If the TPQDELIVERYQOS flag is set, the flags specified by ctl‑>delivery_qos control the quality of service for delivery of the message. In this case, one of three mutually exclusive flags— TPQQOSDEFAULTPERSIST, TPQQOSPERSISTENT, or TPQQOSNONPERSISTENT—must be set in ctl‑>delivery_qos. If TPQDELIVERYQOS is not set, the default delivery policy of the target queue dictates the delivery quality of service for the message.
If the TPQREPLYQOS flag is set, the flags specified by ctl‑>reply_qos control the quality of service for any reply to the message. In this case, one of three mutually exclusive flags—TPQQOSDEFAULTPERSIST, TPQQOSPERSISTENT, or TPQQOSNONPERSISTENT—must be set in ctl‑>reply_qos. The TPQREPLYQOS flag is used when a reply is returned from messages processed by TMQFORWARD. Applications not using TMQFORWARD to invoke services may use the TPQREPLYQOS flag as a hint for their own reply mechanism.
If TPQREPLYQOS is not set, the default delivery policy of the ctl‑>replyqueue queue dictates the delivery quality of service for any reply. Note that the default delivery policy is determined when the reply to a message is enqueued. That is, if the default delivery policy of the reply queue is modified between the time that the original message is enqueued and the reply to the message is enqueued, the policy used is the one in effect when the reply is finally enqueued.
The following is the list of valid flags for ctl‑>delivery_qos and ctl‑>reply_qos:
TPQQOSDEFAULTPERSIST
This flag specifies that the message is to be delivered using the default delivery policy specified on the target queue.
TPQQOSPERSISTENT
This flag specifies that the message is to be delivered in a persistent manner using the disk-based delivery method. Setting this flag overrides the default delivery policy specified on the target queue.
TPQQOSNONPERSISTENT
This flag specifies that the message is to be delivered in a non-persistent manner using the memory-based delivery method. Specifically, the message is queued in memory until it is dequeued. Setting this flag overrides the default delivery policy specified on the target queue. If the caller is transactional, non-persistent messages are enqueued within the caller’s transaction, however, non-persistent messages are lost if the system is shut down, crashes, or the IPC shared memory for the queue space is removed.
TPQEXPTIME_ABS
If this flag is set, the message has an absolute expiration time, which is the absolute time when the message will be removed from the queue.
The absolute expiration time is determined by the clock on the machine where the queue manager process resides.
The absolute expiration time is indicated by the value stored in ctl‑>exp_time. The value of ctl‑>exp_time must be set to an absolute time value generated by time(2), mktime(3C), or gp_mktime(3c) (the number of seconds since 00:00:00 Universal Coordinated Time—UTC, January 1, 1970).
If an absolute time is specified that is earlier than the time of the enqueue operation, the operation succeeds, but the message is not counted for the purpose of calculating thresholds. If the expiration time is before the message availability time, the message is not available for dequeuing unless either the availability or expiration time is changed so that the availability time is before the expiration time. In addition, these messages are removed from the queue at expiration time even if they were never available for dequeuing. If a message expires while it is within a transaction, the expiration does not cause the transaction to fail. Messages that expire while being enqueued or dequeued within a transaction are removed from the queue when the transaction ends. There is no notification that the message has expired.
TPQEXPTIME_ABS, TPQEXPTIME_REL, and TPQEXPTIME_NONE are mutually exclusive flags. If none of these flags is set, the default expiration time associated with the target queue is applied to the message.
TPQEXPTIME_REL
If this flag is set, the message has a relative expiration time, which is the number of seconds after the message arrives at the queue that the message is removed from the queue. The relative expiration time is indicated by the value stored in ctl‑>exp_time.
If the expiration time is before the message availability time, the message is not available for dequeuing unless either the availability or expiration time is changed so that the availability time is before the expiration time. In addition, these messages are removed from the queue at expiration time even if they were never available for dequeuing. The expiration of a message during a transaction, does not cause the transaction to fail. Messages that expire while being enqueued or dequeued within a transaction are removed from the queue when the transaction ends. There is no acknowledgment that the message has expired.
TPQEXPTIME_ABS, TPQEXPTIME_REL, and TPQEXPTIME_NONE are mutually exclusive flags. If none of these flags is set, the default expiration time associated with the target queue is applied to the message.
TPQEXPTIME_NONE
Setting this flag indicates that the message should not expire. This flag overrides any default expiration policy associated with the target queue. A message can be removed by dequeuing it or by deleting it via an administrative interface.
TPQEXPTIME_ABS, TPQEXPTIME_REL, and TPQEXPTIME_NONE are mutually exclusive flags. If none of these flags is set, the default expiration time associated with the target queue is applied to the message.
Additionally, the urcode element of TPQCTL 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 the TPQCTL structure:
long flags; /* indicates which of the values
* are set */
char msgid[32]; /* ID of enqueued message */
long diagnostic; /* indicates reason for failure */
The following is a valid bit for the flags parameter controlling output information from tpenqueue(). If this flag is turned on when tpenqueue() is called, the /Q server TMQUEUE(5) populates the associated element in the structure with a message identifier. If this flag is turned off when tpenqueue() is called, TMQUEUE() does not populate the associated element in the structure with a message identifier.
TPQMSGID
If this flag is set and the call to tpenqueue() is successful, the message identifier is stored in ctl−>msgid. The entire 32 bytes of the message identifier value are significant, so the value stored in ctl−>msgid is completely initialized (for example, padded with NULL characters). The actual padding character used for initialization varies between releases of the Oracle Tuxedo ATMI /Q component.
The remaining members of the control structure are not used on input to tpenqueue().
If the call to tpenqueue() failed and tperrno is set to TPEDIAGNOSTIC, a value indicating the reason for failure is returned in ctl−>diagnostic. The possible values are defined below in the Diagnostics section.
If this parameter is NULL, the input flags are considered to be TPNOFLAGS and no output information is made available to the application program.
Return Values
Upon failure, tpenqueue() returns -1 and sets tperrno to indicate the error condition. Otherwise, the message has been successfully queued when tpenqueue() returns.
Errors
Upon failure, tpenqueue() sets tperrno to one of the following values. (Unless otherwise noted, failure does not affect the caller’s transaction, if one exists.)
[TPEINVAL]
Invalid arguments were given (for example, qspace is NULL, data does not point to space allocated with tpalloc(), or flags are invalid).
[TPENOENT]
Cannot access the qspace because it is not available (that is, the associated TMQUEUE(5) server is not available), or cannot start a global transaction due to the lack of entries in the Global Transaction Table (GTT).
[TPETIME]
This error code indicates that either a timeout has occurred or tpenqueue() has been attempted, in spite of the fact that the current transaction is already marked rollback only.
If the caller is in transaction mode, then either the transaction is already rollback only or a transaction timeout has occurred. The transaction is marked abort-only. If the caller is not in transaction mode, a blocking timeout has occurred. (A blocking timeout cannot occur if TPNOBLOCK and/or TPNOTIME is specified.)
If a transaction timeout has occurred, then, with one exception, any attempts to send new requests or receive outstanding replies will fail with TPETIME until the transaction has been aborted. The exception is a request that does not block, expects no reply, and is not sent on behalf of the caller’s transaction (that is, tpacall() with TPNOTRAN, TPNOBLOCK, and TPNOREPLY set).
When a service fails inside a transaction, the transaction is put into the TX_ROLLBACK_ONLY state. This state is treated, for most purposes, as though it were equivalent to a timeout. All further ATMI calls for this transaction (with the exception of those issued in the circumstances described in the previous paragraph) will fail with TPETIME.
[TPEBLOCK]
A blocking condition exists and TPNOBLOCK was specified.
[TPGOTSIG]
A signal was received and TPSIGRSTRT was not specified.
[TPEPROTO]
tpenqueue() was called improperly.
[TPESYSTEM]
An Oracle Tuxedo system error has occurred. The exact nature of the error is written to a log file.
[TPEOS]
An operating system error has occurred.
[TPEDIAGNOSTIC]
Enqueuing a message on the specified queue failed. The reason for failure can be determined by the diagnostic returned via ctl.
Diagnostic
The following diagnostic values are returned during the enqueuing of a message:
[QMEINVAL]
An invalid flag value was specified.
[QMEBADRMID]
An invalid resource manager identifier was specified.
[QMENOTOPEN]
The resource manager is not currently open.
[QMETRAN]
The call was not in transaction mode or was made with the TPNOTRAN flag set and an error occurred trying to start a transaction in which to enqueue the message. This diagnostic is not returned by queue managers from Oracle Tuxedo release 7.1 or later.
[QMEBADMSGID]
An invalid message identifier was specified.
[QMESYSTEM]
A system error occurred. The exact nature of the error is written to a log file.
[QMEOS]
An operating system error occurred.
[QMEABORTED]
The operation was aborted. When executed within a global transaction, the global transaction has been marked rollback-only. Otherwise, the queue manager aborted the operation.
[QMEPROTO]
An enqueue was done when the transaction state was not active.
[QMEBADQUEUE]
An invalid or deleted queue name was specified.
[QMENOSPACE]
Due to an insufficient resource, such as no space on the queue, the message with its required quality of service (persistent or non-persistent storage) was not enqueued. QMENOSPACE is returned when any of the following configured resources is exceeded: (1) the amount of disk (persistent) space allotted to the queue space, (2) the amount of memory (non-persistent) space allotted to the queue space, (3) the maximum number of simultaneously active transactions allowed for the queue space, (4) the maximum number of messages that the queue space can contain at any one time, (5) the maximum number of concurrent actions that the Queuing Services component can handle, or (6) the maximum number of authenticated users that may concurrently use the Queuing Services component.
[QMERELEASE]
An attempt was made to enqueue a message to a queue manager that is from a version of the Oracle Tuxedo system that does not support a newer feature.
[QMESHARE]
When enqueuing a message from a specified queue, the specified queue is opened exclusively by another application. The other application is one based on an Oracle product other than the Oracle Tuxedo system that opened the queue for exclusive read and/or write using the Queuing Services API (QSAPI).
See Also
qmadmin(1), gp_mktime(3c), tpacall(3c), tpalloc(3c), tpdequeue(), tpinit(3c), tpsprio(3c), APPQ_MIB(5), TMQFORWARD(5), TMQUEUE(5)
tpqattach()
Name
tpqattach()—Connects an application program to the OTMQ message queuing space by attaching it to a message queue.
Synopsis
#include <atmi.h>
#include <tmqentry.h>
#include <tmqreturn.h>
int tpqattach (qspace, queue, ctl, qattachctl, flags)
Description
A message queue qspace is a collection of message queues that reside on a system, share global memory sections and files, and are served by the same server processes. An OTMQ message queue is an area of memory or disk where messages are stored and retrieved. See the installation and configuration guide for the platform you are using to learn how to configure the OTMQ environment.
To receive OTMQ messages, an application must attach to at least one message queue. The tpqattach function enables an application to attach in the following ways:
An application can attach to a queue by specifying a name. To attach by name, the message queue must be created by run createqueue command of tmqadmin. Attaching by name enables an application to attach to a specific queue, send messages to the queue, and retrieve messages sent to that queue.
An application can attach to a queue by specifying the queue alias. To attach by name alias, the message queue must be created by running the tmqadmin createqueue command. Attaching by name alias enables an application to attach to a specific queue, send messages to the queue, and retrieve messages sent to that queue. In addition, attaching by name alias eliminates the need to change code or recompile if the queue name alias changes. Therefore, attaching by name alias protects applications from changes in the OTMQ environment configuration.
Applications can specify an attachment as primary or secondary. All applications must have a primary queue. In addition, applications can attach to one or more secondary queues. Primary queues can be configured in the queue create command as the owners of secondary queues. When an application attaches to a primary queue that is the owner of secondary queues, the application is automatically attached to the secondary queues at the same time it is attached to the primary queue.
In addition, an application can attach to a multi-resource queue. A multi-resource queue can be read by many applications and is configured as part of the group definition.
Table 1‑2 lists tpqattach() supported arguments:
 
qspace
Supplies the queue space name for enqueue the message. The max length is 15.
queue
Supplies the name of the permanent queue to attach to the application if the attach_mode argument specifies attachment by queue name or queue alias. Queue names are alphanumeric strings with no embedded spaces and allow the following special characters: underscore (_), hyphen (-), and dollar sign ($). The max length is 127.
References to queue names are case sensitive and must match the queue name entered in the create queue command by tmqadmin. Some example queue names are: QUEUE_1, high-priority, and My$Queue.
ctl
The TPQCTL structure is used by the application program to pass and retrieve parameters associated with enqueuing the message. The TPQCTL flags element is used to indicate what other elements in the structure are valid.
On input to tpenqplus(), the elements shown in Listing 1‑1may be set in the TPQCTL structure.
Listing 1‑1 tpenqplus() Elements
     long flags; /* indicates which of the values are set */
     long deq_time; /* absolute/relative time for dequeuing */
     long priority; /* enqueue priority */
     long diagnostic; /* indicates reason for failure */
     char msgid[TMMSGIDLEN]; /* id of message before which to queue */
     char corrid[TMCORRIDLEN];/* correlation id used to identify message */
     char replyqueue[TMQNAMELEN+1]; /* queue name for reply message */
     char failurequeue[TMQNAMELEN+1];/* queue name for failure message */
     CLIENTID cltid;    /* client identifier for originating client */
     long urcode; /* application user-return code */
     long appkey; /* application authentication client key */
     long delivery_qos; /* delivery quality of service */
     long reply_qos; /* reply message quality of service */
     long exp_time; /* expiration time */
     /* new members for TMQPlus */
     long block; /* specify block mode: WF, AK, NN */
     long DIP;    /* specify the delivery interesting point:MEM, SAF, DQF,      DEQ, ACK,      CONF      */
     long uma; /* undelivered message action */
     long msg_class; /* message class */
     long msg_type; /* message type */
     PSB status_block; /* message delivery control point and UMA status      block */
     long redeliver_count; /* the max count which the message can be      redelivered */
     long seq_number[2]; /* message seq number, which is decided in      client side to      decrease the TMQ load */
     long timeout; /* timeout value for block enq/deq operation */
     char src_qspace[TMQSNAMELEN+1]; /* the source QSpace name. */
     char src_qname[TMQNAMELEN+1]; /* the source queue name. */
     char tgt_qspace[TMQSNAMELEN+1]; /* the source QSpace name. */
     char tgt_qname[TMQNAMELEN+1]; /* the source queue name. */
     char orig_src_qspace[TMQSNAMELEN+1];/* the original source QSpace      name. */
     char orig_src_qname[TMQNAMELEN+1]; /* the original source queue name.      */
     char orig_tgt_qspace[TMQSNAMELEN+1];/* the original target QSpace      name. */
     char orig_tgt_qname[TMQNAMELEN+1]; /* the original target queue name.      */
     char hops; /* net hops */
     long opcode;
     long filter_idx;
     long user_tag;
     long geta_idx; /* index of pending pams_get_msga requests */
     long endian;
     long receipt_msg_type; /*used for uma message*/
 
Qattachctl
The is used by the application program to pass parameters associated with attach the queue. The elements shown in Listing 1‑2 may be set in the Q_ATTACH_CTL structure:
Listing 1‑2 Q_ATTACH_CTL Elements
     TM32I attachmode; /* Supplies the mode for attaching the application      to a message queue.*/
     TM32I qtype; /* Supplies the queue type for the attachment. */
     TM32I * namespace_list; /* Supplies a list of name tables to search      when the attach_mode argument. */
     TM32I namespace_list_len; /* Supplies the number of entries in      the name_space_list      argument. */
     long timeout; /* The number of OTMQ time units (1 second      intervals) to allow for the attach to complete. */
 
Flags
TPNOTRAN
If the caller is in transaction mode and this flag is set, the message is not queued within the caller transaction. A caller in transaction mode that sets this flag is still subject to the transaction timeout (and no other), when queuing the message. If message queuing fails, the caller transaction is not affected.
TPNOBLOCK
Caller attaches to the queue if a blocking condition exists. If this flag is set and a blocking condition exists (such as the internal buffers into which the message is transferred are full), the call fails and tperrno is set to TPEBLOCK. If this flag is set and a blocking condition exists because the target queue is opened exclusively by another application, the call fails, tperrno is set to TPEDIAGNOSTIC, and the diagnostic field of the TPQCTL structure is set to QMESHARE. In the latter case, the other application, which is based on an Oracle product other than the Oracle Tuxedo ATMI system, opened the queue for exclusive read and/or write using the Queuing Services API (QSAPI).
When TPNOBLOCK is not set and a blocking condition exists, the caller blocks until the condition subsides or a timeout occurs (either transaction or blocking timeout). If a timeout occurs, the call fails and tperrno is set to TPETIME.
TPNOTIME
Setting this flag signifies that the caller is willing to block indefinitely and wants to be immune to blocking timeouts. Transaction timeouts may still occur.
TPSIGRSTRT
If this flag is set and a signal interrupts any underlying system calls, the interrupted system call is reissued. If TPSIGRSTRT is not set and a signal interrupts a system call, tpenqueue() fails and tperrno is set to TPGOTSIG.
Return Value(s)
[TPEINVAL]
Invalid arguments were given.
[TPENOENT]
Cannot access the qspace because it is not available
[TPETIME]
This error code indicates that either a timeout has occurred or tpqattach() has been attempted, in spite of the fact that the current transaction is already marked rollback only.
[TPEBLOCK]
A blocking condition exists and TPNOBLOCK was specified.
[TPESYSTEM]
An Oracle Tuxedo system error has occurred. The exact nature of the error is written to a log file.
[TPEOS]
An operating system error has occurred.
[TPEDIAGNOSTIC]
Attach to the specified queue failed. The reason for failure can be determined by the diagnostic returned via ctl.
Diagnostic:
[QMEINVAL]
An invalid flag value was specified.
[QMESYSTEM]
A system error occurred. The exact nature of the error is written to a log file.
[QMEOS]
An operating system error occurred.
[QMEABORTED]
The operation was aborted. When executed within a global transaction, the global transaction has been marked rollback-only. Otherwise, the queue manager aborted the operation.
[QMEBADQUEUE]
An invalid or deleted queue name was specified.
tpqdetach()
Name
tpqdetach()—Detaches a selected message queue or all of the application message queues from the message queuing qspace.
Synopsis
#include <atmi.h>
#include <tmqentry.h>
#include <tmqreturn.h>
int tpqdetach ( qspace, queue, detach_opt_list, detach_opt_len, msg_flushed , flags)
Description
Detaches a selected message queue or all of the application's message queues from the message queuing qspace. When an application detaches from its primary queue, this function automatically detaches all secondary queue attachments defined for the primary queue. When the last message queue has been detached, the application is automatically detached from the OTMQ message queuing qspace.
If you are using implicit confirmation with recoverable messaging, you must ensure that the last message is confirmed before:
If you do not ensure that the last message was confirmed before detaching or exiting, the message will be re-delivered when the queue is reattached. The easiest method to ensure confirmation is to save the PSB delivery status of the last message received, check it for the required confirmation status, and then exit after the message has been confirmed.
Table 1‑3 lists tpqdetach() supported arguments.
 
qspace
Supplies the queue space of the queue to be detached. This function can be used to detach primary, secondary, and multi-resource queues.
queue
Supplies the queue name to be detached.
detach_opt_list
Supplies an array of int values used to control how the queue is detached. The predefined constants for this argument are:
TMQ_NOFLUSH_Q
Detaches the queue without flushing the pending messages stored in memory no matter the input parameter queue. The default action is to flush pending messages in the queue before it is detached. Messages are never flushed from multi-resource queues.
TMQ_DETACH_ALL
Detaches all of the application's message queues from the message queuing qspace. Using this constant performs the same action as calling the tpqexit function.
TMQ_CANCEL_SEL
Cancels all selection masks that reference the queue or queues that you are detaching. If you do not select this option and you do not cancel selection masks, OTMQ invalidates all selection masks that reference the queue or queues that you are detaching. You must cancel the invalidated selection masks using the tpqcancelget function.
detach_opt_len
Supplies the number of int values in the detach_opt_list array. The maximum number of int values is 32767.
msgs_flushed
Receives the number of messages that were flushed from the queue. Message count statistics are enabled on all systems by default; therefore, it is not necessary to enable statistics on UNIX and Windows NT systems in order to properly return this value.
flags
The following is a list of valid flags:
Return Value(s)
Upon failure, tpqdetach() returns -1 and sets tperrno to indicate the error condition. Otherwise, the queue has been successfully detached when tpqdetach() returns.
Errors:
[TPEINVAL]
Invalid arguments were given.
[TPENOENT]
Cannot access the qspace because it is not available
[TPETIME]
This error code indicates that either a timeout has occurred or tpqdetach() has been attempted, in spite of the fact that the current transaction is already marked rollback only.
[TPEBLOCK]
A blocking condition exists and TPNOBLOCK was specified.
[TPGOTSIG]
A signal was received and TPSIGRSTRT was not specified.
[TPEPROTO]
tpqdetach() was called improperly.
[TPESYSTEM]
An Oracle Tuxedo system error has occurred. The exact nature of the error is written to a log file.
[TPEOS]
An operating system error has occurred.
tpqbind()
Name
tpqbind() —Dynamically associates a queue name to a queue reference at run-time.
Synopsis
#include <atmi.h>
#include <tmqentry.h>
#include <tmqreturn.h>
int tpqbind (qspace , pNameCtl , scope, timeout);
Description
Dynamically associates a queue name to a queue reference at run-time. This enables a server application to dynamically sign up to service a queue alias at run-time. Thus, an end user can access a service without having to be aware that its normal host computer is down and that the service is being provided from another host computer. To use tpqbind(), you must first invoke tpqattach().
Table 1‑4 lists the tpqbind() supported arguments:
 
qspace
Identifies the queue space to be bound. The qspace argument must same with the qspace argument of tpqattach().
pNameCtl
The Q_NAME_CTL structure is used by the application program to pass and retrieve parameters associated with bind alias to queue name
typedef struct {
char pName[TMQALIASLEN+1];
char pGroup[TMQSNAMELEN+1];
char pQueue[TMQNAMELEN+1];
TM32I nFlags;
TM32I nType; /* L/G */
TM32I type; /* client type */
TM32I nOwnerPid; /* client pid */
CLIENTID cltid;
TM32I * namespace_list; /* for using pams interface */
TM32I namespace_list_len; /* for using pams interface */} Q_NAME_CTL;
pName
Alias name for bind, identifies a global queue reference or a local queue reference.
pGroup
Identifies the queue space to be bound.
pQueue
Queue name.
Note: pGroup and pQueue values specified to this argument controls whether the queue name is bound or unbound:
If the queue pGroup and pQueue are specified, this function binds it to a pName. "If 0 is specified, this function unbinds the pName from its queue name. The calling application must be bound to pName to set it back to zero.”
name_space_list
The name_space_list argument also controls the cache access as follows:
To lookup a local queue reference or queue name, specify both OTMQ _TBL_GRP and OTMQ _TBL_PROC. This causes the process cache to be checked before looking into the group cache.
To lookup a global queue reference, specify OTMQ_TBL_BUS OTMQ _TBL_GRP and OTMQ _TBL_PROC. This causes the process cache to be checked. Then, the group cache is checked before looking into the global name space.
Note that to lookup all caches in the global name space before looking in the master database, specify OTMQ _TBL_BUS_LOW instead of OTMQ _TBL_BUS.
To lookup only the slower but more up-to-date caches in the global name space before looking in the master database, specify OTMQ _TBL_BUS_MEDIUM instead of OTMQ _TBL_BUS.
name_space_list_len
Supplies the number of entries in the name_space_list argument. If the name_space_list_len argument is zero, uses OTMQ_TBL_GRP as the default in the name_space_list argument.
nFlags
CORE_FLAGS_BOUND: binds the alias to the queue name
CORE_FLAGS_CACHED: cache the alias to locale share memory.
CORE_FLAGS_LOCKED: lock the alias. If it is locked, it cannot be accessed.
nOwnerPid
Not used
nType
Not usedN
cltid
Not used.
scope
Specifies the scope for pName. The identifier for scope:
NAME_SCOPE_P: scope is process
NAME_SCOPE_L: scope is local
NAME_SCOPE_G: scope is global
For TP APIs, scope and namespace_list arguments, If scope is NULL, namespace_list must not NULL too, and if scope has a data value, namespace_list will invalidate.
timeout
The number of OTMQ time units (1 second intervals) to allow for the attach to complete. If a null pointer is specified, the BLOCKTIME property of the group's attach service is used (configured in the UBBCONFIG *SERVICES section). If service-wide BLOCKTIME is not configured, system-wide BLOCKTIME specified in the UBBCONFIG *RESOURCES section is used (default to approximately 60 seconds).
Return Value(s)
Upon failure, tpqbind() returns -1 and sets tperrno to indicate the error condition. Otherwise, the queue alias has been successfully binded when tpqbind() returns.
Errors:
[TPEINVAL]
Invalid arguments were given.
[TPENOENT]
Cannot access the qspace because it is not available
[TPETIME]
This error code indicates that either a timeout has occurred or tpqbind() has been attempted, in spite of the fact that the current transaction is already marked rollback only.
[TPEPROTO]
tpqbind() was called improperly. For example, invoke tpqbind without invoke tpqattach() first.
[TPESYSTEM]
An Oracle Tuxedo system error has occurred. The exact nature of the error is written to a log file.
[TPEOS]
An operating system error has occurred.
tpqlocate()
Name
tpqlocate() —Locates the queue name for the specified queue name or queue alias.
Synopsis
#include <atmi.h>
#include <tmqentry.h>
#include <tmqreturn.h>
int tpqlocate (qspace, pNameCtl, req_id, resp_q, scope, wait_mode, timeout )
Description
Locates the queue name for the specified queue name or queue alias. By default, this function waits for the queue name to be returned. To use tpqlocate(), you must first invoke tpqattach().
Table 1‑5 lists tpqlocate() supported arguments:
 
qspace
Supplies the queue space whose queue name is requested. Must be same with the tpqattach() qspace argument.
pNameCtl
The Q_NAME_CTL structure is used by the application program to pass and retrieve parameters associated with bind alias to queue name
typedef struct {
char pName[TMQALIASLEN+1];
char pGroup[TMQSNAMELEN+1];
char pQueue[TMQNAMELEN+1];
TM32I nFlags;
TM32I nType; /* L/G */
TM32I type; /* client type */
TM32I nOwnerPid; /* client pid */
CLIENTID cltid;
TM32I * namespace_list; /* for using pams interface */
TM32I namespace_list_len; /* for using pams interface */
} Q_NAME_CTL;
pName
Alias name for bind, Identifies a global queue reference or a local queue reference.
pGroup
qspace, identifies the qspace name of the alias bind.
pQueue
queue name, identifies the queue name of the alias bind.
pGroup and pQueue values specified to this argument controls whether the queue name is bound or unbound:
If the queue pGroup and pQueue are specified, this function binds it to a pName.
If 0 is specified, this function unbinds the pName from its queue name. The calling application must be bound to pName to set it back to zero.
name_space_list
The name_space_list argument also controls the cache access as follows:
To lookup a local queue reference or queue name, specify both OTMQ_TBL_GRP and OTMQ_TBL_PROC. This causes the process cache to be checked before looking into the qspace cache.
To lookup a global queue reference, specify OTMQ_TBL_BUS, OTMQ _TBL_GRP and OTMQ_TBL_PROC. This causes the process cache to be checked. Then, the qspace cache is checked before looking into the global name space.
Note: that to lookup all caches in the global name space before looking in the master database, specify OTMQ_TBL_BUS_LOW instead of OTMQ _TBL_BUS.
To lookup only the slower but more up-to-date caches in the global name space before looking in the master database, specify OTMQ_TBL_BUS_MEDIUM instead of OTMQ_TBL_BUS.
name_space_list_len
Supplies the number of entries in the name_space_list argument. If the name_space_list_len argument is zero, uses OTMQ_TBL_GRP as the default in the name_space_list argument.
nFlags
CORE_FLAGS_BOUND: binds the alias to the queue name
CORE_FLAGS_CACHED: cache the alias to locale share memory.
CORE_FLAGS_LOCKED: lock the alias.
nOwnerPid
Reserved for future use
nType
Reserved for future use
cltid
Reserved for future use
wait_mode
Supplies the search mode of the tpqlocate function. The mode indicates whether the application waits for the search completion or receives the response in an acknowledgment message. There are two predefined constants for this argument:
"OTMQ_WF_RESP (default setting)-The application issues the tpqlocate request and waits for the queue name to be returned.
"OTMQ_AK_RESP-The application issues the tpqlocate name and continues processing. When the search is completed, the queue name is returned to the application's primary queue in a LOCATE_Q_REP message. The response message can be redirected to an alternate queue name using the resp_q argument, The details of LOCATE_Q_REP message as next.
req_id
Supplies an application-specified transaction ID to associate with the tpqlocate function.
resp_q
Supplies an alternate queue to use for receiving the acknowledgment message of the queue name. If no response queue is specified, the acknowledgment message is sent to the sender program primary queue.
Note: the sender program cannot specify a response queue outside its qspace.
The name_space_list argument also controls the cache access as follows:
To lookup a local queue reference or queue name, specify both OTMQ _TBL_GRP and OTMQ_TBL_PROC. This causes the process cache to be checked before looking into the group cache.
To lookup a global queue reference, specify OTMQ_TBL_BUS (or OTMQ _TBL_BUS_LOW or OTMQ _TBL_BUS_MEDIUM), OTMQ _TBL_GRP and OTMQ _TBL_PROC. This causes the process cache to be checked. Then, the group cache is checked before looking into the global name space.
Note that to lookup all caches in the global name space before looking in the master database, specify OTMQ _TBL_BUS_LOW instead of OTMQ _TBL_BUS.
To lookup only the slower but more up-to-date caches in the global name space before looking in the master database, specify OTMQ _TBL_BUS_MEDIUM instead of OTMQ _TBL_BUS.
name_space_list_len:
Supplies the number of entries in the name_space_list argument. If the name_space_list_len argument is zero, uses OTMQ_TBL_GRP as the default in the name_space_list argument.
scope
Specifies the scope for pName.
The identifies for scope:
NAME_SCOPE_P: scope is process
NAME_SCOPE_L: scope is local
NAME_SCOPE_G: scope is global
For TP APIs scope and namespace_list arguments, if scope is NULL, namespace_list must not NULL too, and if scope has a data value, namespace_list will invalidate.
timeout
The number of OTMQ time units (1 second intervals) to allow for the attach to complete. If a null pointer is specified, the BLOCKTIME property of the group's attach service is used (configured in the UBBCONFIG *SERVICES section). If service-wide BLOCKTIME is not configured, system-wide BLOCKTIME specified in the UBBCONFIG *RESOURCES section is used (default to approximately 60 seconds).
Return Value(s)
Upon failure, tpqlocate() returns -1 and sets tperrno to indicate the error condition. Otherwise, the queue has been successfully located when tpqlocate () returns.
Errors:
[TPEINVAL]
Invalid arguments were given.
[TPENOENT]
Cannot access the qspace because it is not available
[TPETIME]
This error code indicates that either a timeout has occurred or tpqlocate() has been attempted, in spite of the fact that the current transaction is already marked rollback only.
[TPEPROTO]
tpqlocate() was called improperly.
[TPESYSTEM]
An Oracle Tuxedo system error has occurred. The exact nature of the error is written to a log file.
[TPEOS]
An operating system error has occurred.
tpenqplus()
Name
tpenqplus() —Locates the queue name for the specified queue name or queue alias.
Synopsis
#include <atmi.h>
#include <tmqentry.h>
#include <tmqreturn.h>
int tpenqplus (qspace, qname, ctl, data, len, flags)
Description
Sends a message to a target queue in target qspace using a set of standard OTMQ delivery modes.
The block and DIP argument of the TPQCTL struct can be used to guarantee message delivery if a system, process, or network fails. Recoverable messages are stored on disk by the message recovery system until they can be delivered to the target queue of the receiver program. When sending a recoverable message, you must specify the uma argument of TPQCTL structure if the message recovery cannot store the message. You must also supply the TPQCTL structure PSB argument to receive the operation return status.
The optional timeout argument lets you set a maximum amount of time for the send operation to complete before the function times out. The optional replyqueue of TPQCTL struct argument allows you to specify an alternate queue for receiving the response messages rather than directing responses to the primary queue of the sender program. In synchronous mode, fail to receive response message from reply queue will cause tpenqplus() return error, but the message may be still sent to target queue successfully.
To use OTMQ features, you must invoke tpqattach before invoke tpenqplus. The tpenqplus qspace argument must be the same same as the tpqattach qspace argument.
If the caller is within a transaction and the TPNOTRAN flag is not set, the message is queued in transaction mode. This has the effect that if tpenqplus() returns successfully and the caller transaction is committed successfully, then the message is guaranteed to be available subsequent to the transaction completing. If the caller transaction is rolled back either explicitly or as the result of a transaction timeout or some communication error, then the message will be removed 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 the TPNOTRAN flag is set. Once tpenqplus() returns successfully, the submitted message is guaranteed to be in the queue. When not in transaction mode, if a communication error or a timeout occurs, the application will not know whether or not the message was successfully stored on the queue.
To use tpenqplus(), you must first invoke tpqattach().
Table 1‑6 lists tpenqplus() supported arguments:
 
qspace
Supplies the queue space name for enqueueing the message. The max length is 15
qname
Supplies the queue name for enqueueing the message, the max length is 127
Control Parameter
The TPQCTL structure is used by the application program to pass and retrieve parameters associated with enqueuing the message. The flags element of TPQCTL is used to indicate what other elements in the structure are valid.
On input to tpenqplus(), the following elements may be set in the TPQCTL structure:
The element of TPQCTL used for OTMQ:
flags
The following is a list of valid bits for the flags parameter controlling input information for tpenqplus().
TPNOFLAGS
TPQTOPI
TPQBEFOREMSGID
TPQTIME_ABS
TPQTIME_REL
TPQPRIORITY
TPQCORRID
TPQREPLYQ
TPQFAILUREQ
TPQDELIVERYQOS, TPQREPLYQOS
TPQEXPTIME_ABS
TPQEXPTIME_REL
TPQEXPTIME_NONE
TPQMSGID
OTMQ
TPQGETBYFILTER
TPQGETMSGA
TPQREADJRN
TPQENDIAN
TPQGETBYSEQNUM
priority
Supplies the priority level for selective message reception. Priority ranges from 0 (lowest priority) to 99 (highest priority).
msg_class
Supplies the class code of message being sent. OTMQ supports the use of symbolic names for class argument values. Symbolic class names should begin with MSG_CLAS_. For information on defining class symbols, see the tmqsym.h include file. On UNIX and Windows NT systems, the tmqsym.h include file cannot be edited. You must create an include file to define type and class symbols for use by your application.
Class symbols reserved by OTMQ are as follows:
Reserved Class Symbol Value
MSG_CLAS_XXX 30000 through 32767 (except 31001-31003)
msg_type
Supplies the type code for the message being sent. OTMQ supports the use of symbolic names for msg_type argument values. Symbolic type names begin with MSG_TYPE_. For information on defining type symbols, see the tmqsym.h include file.
OTMQ has reserved the symbol value range -1 through -5000. A zero value for this argument indicates that no processing by message type is expected.
block
Supplies the delivery mode for the message using the following format:
OTMQ_DEL_sn-where sn is one of the following sender notification constants:
WF-Wait for completion.
AK-Asynchronous acknowledgment
NN-No notification
Note: NN mode does not support transaction, TPNOTRAN flag is set automatically for this mode.
DIP
Dip is one of the following delivery interest point constants:
"ACK-Read from target queue and explicitly acknowledged using the tpqconfirmmsg function. ACK can also be an implicit acknowledgement sent after the second tpdeqplus call by the receiving application.
"CONF-Delivered from the DQF and explicitly confirmed using the tpqconfirmmsg function (recoverable)
"DEQ-Read from the target queue
"DQF-Stored in the destination queue file (recoverable)
"MEM-Stored in the target queue
"SAF-Stored in the store and forward file (recoverable)
Note: If temporary queues are used, deleted, and reused quickly, it is possible in isolated cases for an implicit ACK response from a previous temporary queue to be placed on the new temporary queue.
If you set OTMQ_DEL_WF and OTMQ_DIP_ACK, the ACK message will be read in tpenqplus, client do not need to call another API to read the ACK message.
timeout
Supplies the maximum amount of time the tpenqplus function waits for a message to arrive before returning control to the application. If the timeout occurs before a message arrives, the status code OTMQ__TIMEOUT is returned. Specifying 0 as the timeout value sets the timeout to the default value of 30 seconds.
psb
Receives a value in the OTMQ Status Block specifying the final completion status. The psb argument is used when sending or receiving recoverable messages. The PSB structure stores the status information from the message recovery system and may be checked after sending or receiving a message as shown in Listing 1‑3.
Listing 1‑3 PSB Structure
Listing 1-3 PSB Structure
struct psb_t {
long type_of_psb; /* PSB type */
long del_psb_status; /* The completion status of the function. It contains the status from TuxMsgQ. It can also contain a value of TPSUCCESS when the message is not sent recoverably. */
long uma_psb_status; /* The completion status of the undeliverable message action (UMA). The PSB UMA status indicates if the UMA was not executed or applicable. */
long psb_reserved[6]; /* reserved filed */
};
typedef struct psb_t PSB;
Note: this structure is already defined at atmi.h.
 
uma
Supplies the action to be performed if the message cannot be stored at the specified -delivery interest point. The format of this argument is OTMQ_UMA_XXX where XXX is one of the following symbols:
Symbol:        Description
DISC:            Discard message
RTS:              Return to sender
SAF:             Store and Forward
DLJ:              Dead letter journal
DLQ:             Dead letter queue
replyqueue
Supplies a q_name to use as the alternate queue for receiving response messages from the receiver program. The sender program must be attached to the queue specified in the replyqueue argument to receive the response messages. To use replyqueue, flags must address TPQREPLYQ.
Note the sender program cannot assign a response queue outside its qspace.
correlation_id
Supplies the correlation id, a user-defined identifier stored as a 32-byte value
seq_number
If the value of seq_number[0] or seq_number[1] is not specified as "(long)0", OTMQ will not generate unique number for this message.
Data
If data is non-NULL, it must point to a buffer previously allocated by tpalloc() and len should specify the amount of data in the buffer that should be queued. Note that if data points to a buffer of a type that does not require a length to be specified (for example, an FML fielded buffer), then len is ignored. If data is NULL, len is ignored and a message is queued with no data portion. Consult tpalloc() for more details.
Len
The length of data, if data is non-NULL.
Flags
The following is a list of valid flags:
TPNOTRAN
If the caller is in transaction mode and this flag is set, the message is not queued within the caller transaction. A caller in transaction mode that sets this flag is still subject to the transaction timeout (and no other) when queuing the message. If message queuing fails, the caller's transaction is not affected.
TPNOBLOCK
The message is not enqueued if a blocking condition exists. If this flag is set and a blocking condition exists such as the internal buffers into which the message is transferred are full, the call fails and tperrno is set to TPEBLOCK. If this flag is set and a blocking condition exists because the target queue is opened exclusively by another application, the call fails, tperrno is set to TPEDIAGNOSTIC, and the diagnostic field of the TPQCTL structure is set to QMESHARE.
When TPNOBLOCK is not set and a blocking condition exists, the caller blocks until the condition subsides or a timeout occurs (either transaction or blocking timeout). If a timeout occurs, the call fails and tperrno is set to TPETIME.
TPNOTIME
Setting this flag signifies that the caller is willing to block indefinitely and wants to be immune to blocking timeouts. Transaction timeouts may still occur.
TPSIGRSTRT
If this flag is set and a signal interrupts any underlying system calls, the interrupted system call is reissued. If TPSIGRSTRT is not set and a signal interrupts a system call, tpenqplus() fails and tperrno is set to TPGOTSIG.
Return Value(s)
Upon failure, tpenqplus() returns -1 and sets tperrno to indicate the error condition. Otherwise, the message has been successfully enque when tpenqplus() returns.
Errors:
[TPEINVAL]
Invalid arguments were given.
[TPENOENT]
Cannot access the qspace because it is not available
[TPETIME]
This error code indicates that either a timeout has occurred or tpenqplus() has been attempted, in spite of the fact that the current transaction is already marked rollback only.
[TPEBLOCK]
A blocking condition exists and TPNOBLOCK was specified.
[TPGOTSIG]
A signal was received and TPSIGRSTRT was not specified.
[TPEPROTO]
tpenqplus() was called improperly.
[TPESYSTEM]
An Oracle Tuxedo system error has occurred. The exact nature of the error is written to a log file.
[TPEOS]
An operating system error has occurred.
[TPEDIAGNOSTIC]
Enqueuing a message on the specified queue failed. The reason for failure can be determined by the diagnostic returned via ctl.
Diagnostic:
[QMEINVAL]
An invalid flag value was specified.
[QMEBADRMID]
An invalid resource manager identifier was specified.
[QMENOTOPEN]
The resource manager is not currently open.
[QMETRAN]
The call was not in transaction mode or was made with the TPNOTRAN flag set and an error occurred trying to start a transaction in which to enqueue the message. This diagnostic is not returned by queue managers from Oracle Tuxedo release 7.1 or later.
[QMEBADMSGID]
An invalid message identifier was specified.
[QMESYSTEM]
A system error occurred. The exact nature of the error is written to a log file.
[QMEOS]
An operating system error occurred.
[QMEABORTED]
The operation was aborted. When executed within a global transaction, the global transaction has been marked rollback-only. Otherwise, the queue manager aborted the operation.
[QMEPROTO]
An enqueue was done when the transaction state was not active.
[QMEBADQUEUE]
An invalid or deleted queue name was specified.
[QMENOSPACE]
Due to an insufficient resource, such as no space on the queue, the message with its required quality of service (persistent or non-persistent storage) was not enqueued.
[QMERELEASE]
An attempt was made to enqueue a message to a queue manager that is from a version of the Oracle Tuxedo system that does not support a newer feature.
[QMBADDELIVERY]
Invalid delivery mode.
[QMBADPRIORITY]
Invalid priority value on send operation.
[QMBADPROCNUM]
Invalid target queue name specified.
[QMBADRESPQ]
Response queue not owned by process.
[QMBADUMA]
Undeliverable message action (UMA) is invalid.
[QMNOTSUPPORTED]
The combination of delivery mode and uma selected is not supported.
tpdeqplus()
Name
tpdeqplus()—Retrieves the next available message from a selected queue and moves it to the location specified in the data argument.
Synopsis
#include <atmi.h>
#include <tmqentry.h>
#include <tmqreturn.h>
int tpdeqplus (qspace, qname, ctl, data, len, flags)
Description
Retrieves the next available message from a selected queue and moves it to the location specified in the data argument. When no selection filter is specified, the function returns the next available message in first-in/first-out (FIFO) order based on message priority to the buffer specified in the data argument. Priority ranges from 0 (lowest priority) to 99 (highest priority). For example, priority 1 messages are always placed before priority 0 messages. Messages are placed in first-in/first out order by message priority. If a selection filter is specified, then only messages that meet the selection criteria are retrieved. If no messages are available or meet the selection criteria, then the return status is QMENOMSG.
Applications should check the PSB status field of each message to determine if the message was sent with a recoverable delivery mode. If an application receives a recoverable message, it must call the tpqconfirmmsg function to delete it from the message recovery journal disk storage. If receipt of a recoverable message is not confirmed, the message continues to be stored by the recovery system and will be re-delivered if the application detaches and then reattaches to the queue.
To use tpdepplus(), you must first invoke tpqattach().
Table 1‑7 lists tpdepplus() supported arguments:
 
qspace
Supplies the queue space name for message dequeue. The max length is 15
qname
Supplies the queue name for message enqueue. The max length is 127
Data
Data is the address of a pointer to the buffer into which a message is read, and len points to the length of that message. *data must point to a buffer originally allocated by tpalloc(). If a message is larger than the buffer passed to tpdeqplus, the buffer is increased in size to accommodate the message. To determine whether a message buffer changed in size, compare its (total) size before tpdeqplus() was issued with *len. If *len is larger, then the buffer has grown; otherwise, the buffer has not changed size. Note that *data may change for reasons other than if the buffer size increased. If *len is 0 upon return, then the message dequeued has no data portion and neither *data nor the buffer it points to were modified. It is an error for *data or len to be NULL. Consult tpalloc() for more details.
The message is dequeued in transaction mode if the caller is in transaction mode and the TPNOTRAN flag is not set. This has the effect that if tpdeqplus() returns successfully and the caller transaction is committed successfully, then the message is removed from the queue. 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 left on the queue (that is, the removal of the message from the queue is also rolled back). It is not possible to enqueue and dequeue the same message within the same transaction.
The message is not dequeued in transaction mode if either the caller is not in transaction mode, or the TPNOTRAN flag is set. When not in transaction mode, if a communication error or a timeout occurs, the application will not know whether or not the message was successfully dequeued and the message may be lost.
Len
The length of data, if data is non-NULL.
ctrl
The TPQCTL structure .
flags
The following is a list of valid bits for the flags parameter controlling input information for tpdeqplus().
TPNOFLAGS
TPQGETBYMSGID
TPQGETBYCORRID
TPQWAIT
TPQPEEK
OTMQ
TPQGETBYFILTER
TPQGETMSGA
TPQREADJRN
TPQENDIAN
TPQGETBYSEQNUM
TPQGETBYMSGCLASS
TPQGETBYMSGTYPE
priority
Supplies the priority level for selective message reception. Priority ranges from 0 (lowest priority) to 99 (highest priority).
msg_class
Supplies the class code of message being sent. OTMQ supports the use of symbolic names for class argument values. Symbolic class names should begin with MSG_CLAS_. For information on defining class symbols, see the tmqsym.h include file. On UNIX and Windows NT systems, the tmqsym.h include file cannot be edited. You must create an include file to define type and class symbols for use by your application.
Class symbols reserved by OTMQ are as follows:
Reserved Class                          Symbol Value
ACK_CLASS                       28
MSG_CLAS_PAMS                   29
TUXEDO_MSG                   31001
MSG_CLAS_TUXEDO_TPSUCCESS    31002
MSG_CLAS_TUXEDO_TPFAIL       31003
MSG_CLAS_XXX                 30000 through 32767
(except 31001-31003)
msg_type
Supplies the type code for the message being sent. OTMQ supports the use of symbolic names for msg_type argument values. Symbolic type names begin with MSG_TYPE_. For information on defining type symbols, see the tmqsym.h include file.
OTMQ has reserved the symbol value range -1 through -5000. A zero value for this argument indicates that no processing by message type is expected.
block
Supplies the delivery mode for the message using the following format:
"OTMQ_DEL_sn-where sn is one of the following sender notification constants:
"WF-Wait for completion
"AK-Asynchronous acknowledgment
"NN-No notification
Note: NN mode does not support transaction, TPNOTRAN flag is set automatically for this mode.
DIP
Dip is one of the following delivery interest point constants:
"ACK-Read from target queue and explicitly acknowledged using the tpqconfirmmsg function. ACK can also be an implicit acknowledgement sent after the second tpdeqplus call by the receiving application.
"CONF-Delivered from the DQF and explicitly confirmed using the tpqconfirmmsg function (recoverable)
"DEQ-Read from the target queue
"DQF-Stored in the destination queue file (recoverable)
"MEM-Stored in the target queue
"SAF-Stored in the store and forward file (recoverable)
Note: If temporary queues are used, deleted, and reused quickly, it is possible in isolated cases for an implicit ACK response from a previous temporary queue to be placed on the new temporary queue.
If set OTMQ_DIP_ACK and OTMQ_DEL_WF, the ACK message will be read in tpenqplus,_client do not need to call another API to read the ACK message.
timeout
Supplies the maximum amount of time the tpenqplus function waits for a message to arrive before returning control to the application. If the timeout occurs before a message arrives, the status code OTMQ_TIMEOUT is returned. Specifying 0 as the timeout value sets the timeout to the default value of 30 seconds.
psb
Receives a value in the OTMQ Status Block specifying the final completion status. The psb argument is used when sending or receiving recoverable messages. The PSB structure stores the status information from the message recovery system and may be checked after sending or receiving a message as shown in Listing 1‑4.
Listing 1‑4 PSB Structure
struct psb_t {
long type_of_psb; /* PSB type */
long del_psb_status; /* The completion status of the function. It contains the status from TuxMsgQ. It can also contain a value of TPSUCCESS when the message is not sent recoverably. */
long uma_psb_status; /* The completion status of the undeliverable message action (UMA). The PSB UMA status indicates if the UMA was not executed or applicable. */
long psb_reserved[6]; /* reserved filed */
};
typedef struct psb_t PSB;
 
Note:
 
Table 1‑8 PSB Delivery
uma
Supplies the action to be performed if the message cannot be stored at the specified -delivery interest point. The format of this argument is OTMQ_UMA_XXX where XXX is one of the following symbols:
Symbol          Description
DISC       Discard message
RTS        Return to sender
SAF        Store and Forward
DLJ        Dead letter journal
DLQ        Dead letter queue
replyqueue
Supplies a q_name to use as the alternate queue for receiving response messages from the receiver program. The sender program must be attached to the queue specified in the replyqueue argument to receive the response messages.The sender program cannot assign a response queue outside its qspace.
correlation_id
Supplies the correlation id, a user-defined identifier stored as a 32-byte value
filter_idx
Get message by filter, filter_idx set as index_handle is created using the tpqsetselect function.
Data
If data is non-NULL, it must point to a buffer previously allocated by tpalloc() and len should specify the amount of data in the buffer that should be queued. Note that if data points to a buffer of a type that does not require a length to be specified (for example, an FML fielded buffer), then len is ignored. If data is NULL, len is ignored and a message is queued with no data portion. Consult tpalloc() for more details.
Len
The length of data, if data is non-NULL.
Flags
The following is
TPNOTRAN
If the caller is in transaction mode and this flag is set, the message is not queued within the caller transaction. A caller in transaction mode that sets this flag is still subject to the transaction timeout (and no other) when queuing the message. If message queuing fails, the caller's transaction is not affected.
TPNOBLOCK
The message is not enqueued if a blocking condition exists. If this flag is set and a blocking condition exists such as the internal buffers into which the message is transferred are full, the call fails and tperrno is set to TPEBLOCK. If this flag is set and a blocking condition exists because the target queue is opened exclusively by another application, the call fails, tperrno is set to TPEDIAGNOSTIC, and the diagnostic field of the TPQCTL structure is set to QMESHARE.
When TPNOBLOCK is not set and a blocking condition exists, the caller blocks until the condition subsides or a timeout occurs (either transaction or blocking timeout). If a timeout occurs, the call fails and tperrno is set to TPETIME.
TPNOTIME
Setting this flag signifies that the caller is willing to block indefinitely and wants to be immune to blocking timeouts. Transaction timeouts may still occur.
TPSIGRSTRT
If this flag is set and a signal interrupts any underlying system calls, the interrupted system call is reissued. If TPSIGRSTRT is not set and a signal interrupts a system call, tpenqplus() fails and tperrno is set to TPGOTSIG.
Return Value(s)
Upon failure, tpdeqplus() returns -1 and sets tperrno to indicate the error condition. Otherwise, the queue has been successfully dequeued when tpdeqplus() returns.
Errors:
Upon failure, tpdeqplus() sets tperrno to one of the following values. (Unless otherwise noted, failure does not affect the caller's transaction, if one exists.)
[TPEINVAL]
Invalid arguments were given.
[TPENOENT]
Cannot access the qspace because it is not available.
[TPEOTYPE]
Either the type and subtype of the dequeued message are not known to the caller; or, TPNOCHANGE was set in flags and the type and subtype of *data do not match the type and subtype of the dequeued message. In either case, *data, its contents, and *len are not changed. When the call is made in transaction mode and this error occurs, the transaction is marked abort-only, and the message remains on the queue.
[TPETIME]
This error code indicates that either a timeout has occurred.
[TPEBLOCK]
A blocking condition exists and TPNOBLOCK was specified.
[TPGOTSIG]
A signal was received and TPSIGRSTRT was not specified.
[TPEPROTO]
tpdeqplus() was called improperly. There is no effect on the queue or the transaction.
[TPESYSTEM]
An Oracle Tuxedo system error has occurred. The exact nature of the error is written to a log file. There is no effect on the queue.
[TPEOS]
An operating system error has occurred. There is no effect on the queue.
[TPEDIAGNOSTIC]
Dequeuing a message from the specified queue failed. The reason for failure can be determined by the diagnostic value returned via ctl structure.
Diagnostic:
The following diagnostic values are returned during the dequeuing of a message:
[QMEINVAL]
An invalid flag value was specified.
[QMEBADRMID]
An invalid resource manager identifier was specified.
[QMENOTOPEN]
The resource manager is not currently open.
[QMEBADMSGID]
An invalid message identifier was specified for dequeuing.
[QMESYSTEM]
A system error has occurred. The exact nature of the error is written to a log file.
[QMEOS]
An operating system error has occurred.
[QMEABORTED]
The operation was aborted. When executed within a global transaction, the global transaction has been marked rollback-only. Otherwise, the queue manager aborted the operation.
[QMEPROTO]
A dequeue was done when the transaction state was not active.
[QMEBADQUEUE]
An invalid or deleted queue name was specified.
[QMENOMSG]
No message was available for dequeuing. Note that it is possible that the message exists on the queue and another application process has read the message from the queue. In this case, the message may be put back on the queue if that other process rolls back the transaction.
[QMBADPRIORITY]
Invalid priority value used for receive.
[QMNOTDCL]
Process has not been attached to OTMQ.
tpqpublish()
Name
tpqpublish()—Used to publish a topic data.
Synopsis
#include <atmi.h>
#include <tmqentry.h>
#include <tmqreturn.h>
int tpqpublish (topic_name, data, len, flags)
Description
The caller uses tpqpublish() to publish a topic data. The topic is named by topic and data, if not NULL, points to the data. The topic and its data are dispatched by the Oracle Tuxedo ATMI EventBroker to all subscribers whose subscriptions successfully evaluate against topic and whose optional filter rules successfully evaluate against data.
Table 1‑9 lists tpqpublish() supported arguments:
 
topicname
topicname is a NULL-terminated string of at most 31 characters and start with "TMQ:<QNOT>:qspace name", such as"TMQ:QNOT:QSPACE:usertopic". The first topicname character cannot be a dot (".") as this character is reserved as the starting character for all events defined by the Oracle Tuxedo ATMI system itself. The topicname "TMQ:QNOT: qspace name" is the suffix for all user topic and can not be used as user topic name alone."QNOT" is not an necessary string. But if topicname cotain "QNOT", means the message which will be published is an AVAIL/UNAVALI message.
Data
If data is non-NULL, it must point to a buffer previously allocated by tpalloc() and len should specify the amount of data in the buffer that should be posted with the event. Note that if data points to a buffer of a type that does not require a length to be specified (for example, an FML fielded buffer), then len is ignored. If data is NULL, len is ignored and the event is posted with no data.
Flags
If the publisher is within a transaction and the TPNOTRAN flag is not set, the publish topic goes to the EventBroker in transaction mode such that it dispatches the event as part of the publisher transaction. The broker dispatches transactional event notifications only to those service routine and stable-storage queue subscriptions that used the TPEVTRAN bit setting in the ctl-? flags parameter passed to tpqsubscribe(). Client notifications, and those service routine and stable-storage queue subscriptions that did not use the TPEVTRAN bit setting in the ctl-? flags parameter passed to tpqsubscribe(), are also dispatched by the EventBroker but not as part of the publiser process transaction.
If the publisher is outside a transaction, tpqpublish() is a one-way publish topic with no acknowledgement when the service associated with the event fails. This occurs even when TPEVTRAN is set for that event (using the ctl.flags parameter passed to tpqsubscribe(). If the publisher is in a transaction, then tpqpublish () returns TPESVCFAIL when the associated service fails in the event.
The following is a list of valid flags:
TPNOTRAN
If the caller is in transaction mode and this flag is set, then the event publishing is not made on behalf of the caller transaction. A caller in transaction mode that sets this flag is still subject to the transaction timeout (and no other) when posting events. If the event posting fails, the caller's transaction is not affected.
TPNOREPLY
Informs tpqpublish() not to wait for the EventBroker to process all subscriptions for topic before returning. When TPNOREPLY is set, tpurcode() is set to zero regardless of whether tpqpublish() returns successfully or not. When the caller is in transaction mode, this setting cannot be used unless TPNOTRAN is also set.
TPNOBLOCK
The topic is not published if a blocking condition exists. If such a condition occurs, the call fails and tperrno is set to TPEBLOCK. When TPNOBLOCK is not specified and a blocking condition exists, the caller blocks until the condition subsides or a timeout occurs (either transaction or blocking timeout).
TPNOTIME
This flag signifies that the caller is willing to block indefinitely and wants to be immune to blocking timeouts. Transaction timeouts may still occur.
TPSIGRSTRT
If a signal interrupts any underlying system calls, then the interrupted system call is reissued. When TPSIGRSTRT is not specified and a signal interrupts a system call, then tpqpublish() fails and tperrno is set to TPGOTSIG.
In a multithreaded application, a thread in the TPINVALIDCONTEXT state is not allowed to issue a call to tpqpublish().
Return Value(s)
Upon failure, tpqpublish() returns -1 and sets tperrno to indicate the error condition. Otherwise, the message has been successfully broadcasted when tpqpublish() returns.
Errors:
[TPEINVAL]
Invalid arguments were given.
[TPENOENT]
Cannot access the TMQEVT
[TPETIME]
This error code indicates that either a timeout has occurred or tpqpublish() has been attempted, in spite of the fact that the current transaction is already marked rollback only.
[TPEBLOCK]
A blocking condition exists and TPNOBLOCK was specified.
[TPGOTSIG]
A signal was received and TPSIGRSTRT was not specified.
[TPEPROTO]
tpqpublish() was called improperly.
[TPESYSTEM]
An Oracle Tuxedo system error has occurred. The exact nature of the error is written to a log file.
[TPEOS]
An operating system error has occurred.
tpqsubscribe()
Name
tpqsubscribe()—Used to subscribe to a topic.
Synopsis
#include <atmi.h>
#include <tmqentry.h>
#include <tmqreturn.h>
long tpqsubscirbe (topic, filter, ctl, flags)
Description
The caller uses tpqsubscribe() to subscribe to a topic. Topic is a NULL-terminated string of at most 255 characters containing a regular expression. If present, filter is a string containing a Boolean filter rule that must be evaluated successfully before the TMQEVT posts the topic. Upon receiving an topic to be published, the TMQEVT applies the filter rule, if one exists, to the publish topic string. If the data passes the filter rule, the TMQEVT invokes the notification method; otherwise, the broker does not invoke the associated notification method. The caller can subscribe to the same event multiple times with different filter rules.
Table 1‑10 lists tpqsubscribe() supported arguments:
 
topic
topic is a NULL-terminated string of at most 31 characters and starts with "TMQ:<QNOT>:qspace name" (for example"TMQ:QNOT:QSPACE:usertopic"). The first topic character cannot be a dot (".") as this character is reserved as the starting character for all events defined by the Oracle Tuxedo ATMI system itself. The topic "TMQ:QNOT: qspace name" is the suffix for all user topics and cannot be used as a user topic name alone."QNOT" is not a necessary string. But if a topic contains "QNOT", it indicates the published message is an AVAIL/UNAVALI message.
filter
filter is a string containing a Boolean filter rule that must be evaluated successfully before the TMQEVT posts the topic. See Regular Expressions.
ctrl
The TPEVCTL structure as shown at atmi.h
This structure contains the following elements:
/* Subscription Control structure */
struct tpevctl_t {
long flags;
char name1[XATMI_SERVICE_NAME_LENGTH];
char name2[XATMI_SERVICE_NAME_LENGTH];
TPQCTL qctl;
};
typedef struct tpevctl_t TPEVCTL;
The following is a list of valid bits for the ctl->flags element controling options for topic subscriptions:
TPEVQUEUE
Setting this flag indicates that the subscriber wants topic notifications to be enqueued to the queue space named in ctl->name1 and the queue named in ctl->name2. That is, when an topic name is published that evaluates successfully against topic, the TMQEVT tests the published data against the filter rule associated with topic. If the data passes the filter rule or if there is no filter rule for the topic, then the TMQEVT enqueues a message to the queue space named in ctl->name1 and the queue named in ctl->name2 along with any data published with the topic. The queue space and queue name can be any valid Oracle Tuxedo ATMI system queue space and queue name, either of which may or may not exist at the time the subscription is made.
ctl->qctl can contain options further directing the TMQEVT enqueuing of the published topic. If no options are specified, then ctl->qctl.flags should be set to TPNOFLAGS. Otherwise, options can be set as described in the "Control Parameter" subsection of tpenqplus. TPEVQUEUE are mutually exclusive flags. If TPEVTRAN is also set in ctl->flags, then if the process calling tpqpublish() is in transaction mode, the TMQEVT enqueues the published topic and its data such that it will be part of the publisher transaction. The TMQEVT must belong to a server group that supports transactions (see UBBCONFIG for details). If TPEVTRAN is not set in ctl->flags, then the TMQEVT enqueues the published topic and its data such that it will not be part of the publisher transaction.
TPEVTRAN
Setting this flag indicates that the subscriber wants the topic notification for this subscription to be included in the publisher transaction, if one exists. If the publisher is not a transaction, then a transaction is started for this topic notification. If this flag is not set, then any topics published for this subscription will not be done on behalf of any transaction in which the publisher is participating.
For subscriptions to stable-storage queues, the queue space, queue name, and correlation identifier are used, in addition to topic and filter, when determining matches. The correlation identifier can be used to differentiate among several subscriptions for the same topic expression and filter rule, destined for the same queue. Thus, if the caller has set ctl->flags to TPEVQUEUE, and TPQCOORID is not set in ctl->qctl.flags, then tpqsubscribe() fails if topic, filter, the queue space name set in ctl->name1, and the queue name set in ctl->name2 match those of a subscription (which also does not have a correlation identifier specified) already known to the TMQEVT. Further, if TPQCOORID is set in ctl->qctl.flags, then tpqsubscribe() fails if topic, filter, ctl->name1, ctl->name2, and ctl->qctl.corrid match those of a subscription (which has the same correlation identifier specified) already known to the TMQEVT.
TPEVPERSIST
By default, the OTMQ deletes subscriptions when the resource to which it is posting is not available (for example, the OTMQ cannot access a service routine and/or a queue space/queue name associated with an subscription). Setting this flag indicates that the subscriber wants this subscription to persist across such errors (usually because the resource will become available again in the future). When this flag is not used, the OTMQ will remove this subscription if it encounters an error accessing either the service name or queue space/queue name designated in this subscription.
If this flag is used with TPEVTRAN and the resource is not available at the time of event notification, then the EventBroker will return to the poster such that its transaction must be aborted. That is, even though the subscription remains intact, the resource's unavailability will cause the poster's transaction to fail.
flags
The following is a list of valid flags for tpqsubscribe():
OTMQ
Note: OTMQ is must be set for TPQCTL->flags.
TPNOBLOCK
The subscription is not made if a blocking condition exists. If such a condition occurs, the call fails and tperrno is set to TPEBLOCK. When TPNOBLOCK is not specified and a blocking condition exists, the caller blocks until the condition subsides or a timeout occurs (either transaction or blocking timeout).
TPNOTIME
This flag signifies that the caller is willing to block indefinitely and wants to be immune to blocking timeouts. Transaction timeouts may still occur.
TPSIGRSTRT
If a signal interrupts any underlying system calls, then the interrupted system call is reissued. When TPSIGRSTRT is not specified and a signal interrupts a system call, then tpqsubscribe() fails and tperrno is set to TPGOTSIG.
In a multithreaded application, a thread in the TPINVALIDCONTEXT state is not allowed to issue a call to tpqsubscribe().
Return Value(s)
Upon failure, tpqsubscribe() returns -1 and sets tperrno to indicate the error condition. Otherwise, the topic has been successfully subscribed when tpqsubscribe() returns and returns a subscription handle.
Errors:
[TPEINVAL]
Invalid arguments were given.
[TPENOENT]
Cannot access TMQEVT
[TPETIME]
This error code indicates that either a timeout has occurred or tpqsubscribe() has been attempted, in spite of the fact that the current transaction is already marked rollback only.
[TPEBLOCK]
A blocking condition exists and TPNOBLOCK was specified.
[TPGOTSIG]
A signal was received and TPSIGRSTRT was not specified.
[TPEPROTO]
tpqsubscribe() was called improperly.
[TPESYSTEM]
An Oracle Tuxedo system error has occurred. The exact nature of the error is written to a log file.
[TPEOS]
An operating system error has occurred.
[TPELIMIT]
The subscription failed because the EventBroker maximum number of subscriptions has been reached.
tpqunsubscribe()
Name
tpqunsubscribe()—Used to remove a subscription.
Synopsis
#include <atmi.h>
#include <tmqentry.h>
#include <tmqreturn.h>
int tpqunsubscirbe (subscription,flags)
Description
Used to remove a subscription.
Table 1‑11 lists tpqunsubscribe() supported arguments:
 
Subscription
subscription is an subscription handle returned by tpqsubscribe().Setting subscription to the wildcard value, -1, directs tpqunsubscribe() to unsubscribe to all non-persistent subscriptions previously made by the calling process. Non-persistent subscriptions are those made without the TPEVPERSIST bit setting in the ctl-?flags parameter of tpqsubscribe(). Persistent subscriptions can be deleted only by using the handle returned by tpqsubscribe().
flags
The following is a list of valid flags for tpqsubscribe():
TPNOBLOCK
The subscription is not made if a blocking condition exists. If such a condition occurs, the call fails and tperrno is set to TPEBLOCK. When TPNOBLOCK is not specified and a blocking condition exists, the caller blocks until the condition subsides or a timeout occurs (either transaction or blocking timeout).
TPNOTIME
This flag signifies that the caller is willing to block indefinitely and wants to be immune to blocking timeouts. Transaction timeouts may still occur.
TPSIGRSTRT
If a signal interrupts any underlying system calls, then the interrupted system call is reissued. When TPSIGRSTRT is not specified and a signal interrupts a system call, then tpunsubscribe() fails and tperrno is set to TPGOTSIG.
In a multithreaded application, a thread in the TPINVALIDCONTEXT state is not allowed to issue a call to tpqunsubscribe().
Return Value(s)
Upon failure, tpqunsubscribe() sets tperrno to one of the following values. (Unless otherwise noted, failure does not affect the caller's transaction, if one exists.)
[TPEINVAL]
Invalid arguments were given.
[TPENOENT]
Cannot access the OTMQ EventBroker.
[TPETIME]
This error code indicates that either a timeout has occurred
[TPEBLOCK]
A blocking condition exists and TPNOBLOCK was specified.
[TPGOTSIG]
A signal was received and TPSIGRSTRT was not specified.
[TPEPROTO]
tpqunsubscribe() was called improperly.
[TPESYSTEM]
An Oracle Tuxedo system error has occurred. The exact nature of the error is written to a log file.
[TPEOS]
An operating system error has occurred.
tpqconfirmmsg()
Name
tpqconfirmmsg()—Confirms receipt of a message that requires explicit confirmation.
Synopsis
#include <atmi.h>
#include <tmqentry.h>
#include <tmqreturn.h>
int tpqconfirmmsg (seq_number, force_j)
Description
Confirms receipt of a message that requires explicit confirmation. This can be a recoverable message sent to a queue that is configured for explicit confirmation or a message sent using the ACK delivery mode which must be explicitly confirmed upon receipt. Applications should examine the PSB status field of each message received to determine if the message requires explicit confirmation.
When a recoverable message is received, the application must call the tpqconfirmmsg function in order to delete it from the message recovery journal disk storage. If receipt of a recoverable message is not confirmed, the message continues to be stored by the recovery system and will be re-delivered if the application detaches and then reattaches to the queue.
OTMQ can confirm receipt of a recoverable message automatically when the next consecutive message in the recovery journal is delivered. This feature is called implicit confirmation.
All queues must be configured for implicit or explicit confirmation. For complete information on how to configure message queues, see tmqadmin in the Oracle Tuxedo Message Queue Command Reference Guide.
Successfully delivered recoverable messages can be recorded in the postconfirmation journal (PCJ). The tpqconfirmmsg function uses the force_j argument to write messages to the PCJ file if the system is not currently configured to store them. Note that successfully delivered recoverable messages cannot be written to the PCJ file unless they are explicitly confirmed using the tpqconfirmmsg function.
To use tpqconfirmmsg(), you must first invoke tpqattach().
Note:
tpqconfirmmsg() is an asynchronous invocation, when it returns, the recoverable message in the recoveray jounal disk storage may not have been deleted by the recovery system.
Table 1‑12 lists tpqconfirmmsg() supported arguments:
 
seq_number
Supplies the message sequence number of the recoverable message being confirmed. The message sequence number is generated by the OTMQ message recovery system for each recoverable message. This value is passed to the receiver program in the PSB of the tpdeqplus function when it reads each recoverable message.
force_j
Supplies the journaling action for this message. Following are the predefined constants for this argument:
 
Return Value(s)
Upon failure, tpqconfirmmsg() sets tperrno to one of the following values. (Unless otherwise noted, failure does not affect the caller's transaction, if one exists.)
[TPEINVAL]
Invalid arguments were given.
[TPENOENT]
Cannot access the qspace because it is not available.
[TPETIME]
This error code indicates that either a timeout has occurred.
[TPESYSTEM]
An Oracle Tuxedo system error has occurred. The exact nature of the error is written to a log file.
[TPEOS]
An operating system error has occurred.
tpqsetselect()
Name
tpqsetselect()—Allows application developers to define complex selection criteria for message reception.
Synopsis
#include <atmi.h>
#include <tmqentry.h>
#include <tmqreturn.h>
int tpqsetselect (selection_array, num_masks, index_handle)
Description
Allows application developers to define complex selection criteria for message reception. The selection array specifies the queues to search, the priority order of message reception, two comparison keys for range checking, and an order key to determine the order in which messages are selected from the queue.
The tpqsetselect function creates an index handle that is used as the sel_filter argument of OTMQ functions for reading the message. When a selection index handle is passed to tpdeqplus, each message received is compared against comparison key_1 and then comparison key_2. If the message matches both keys (a logical AND operation), the message is added to a set of matched messages. The order in which selected messages are delivered is determined by the order key.
To use tpqsetselect(), you must first invoke tpqattach().
Table 1‑13 lists tpqsetselect() supported arguments:
 
selection_array
Supplies an array of selection records that contain the selection rules for each queue. The typedef structures define the C data structure for the selection array. The structure is defined in tmqentry.h as follows:
typedef struct _selection_array_component_tp {
char qspace[TMQSNAMELEN+1];
char queue[QNAMELEN+1];
    TM32I priority;
TM32I key_1_offset;
TM32I key_1_size;
TM32I key_1_value;
TM32I key_1_oper;
TM32I key_2_offset;
TM32I key_2_size;
TM32I key_2_value;
TM32I key_2_oper;
TM32I order_offset;
TM32I order_size;
TM32I order_order;
    char key_value_qspace[TMQSNAMELEN+1];
    char key_value_queue[TMQNAMELEN+1];
union {
otmq_correlation_id correlation_id;
otmq_sequence_number sequence number
} extended_key
} selection_array_component_tp;
The selection_array_component_tp data structure has the following components:
 
Table 1‑15 specifies the valid values that can be applied to the arguments in this part of the Select_Queue structure:
 
 
 
Table 1‑15 Queue and Priority
Specifies the queue name to be searched. The queue name can be any message queue for which the application has read access. The queue name can be obtained from the q_attached argument of the tpqattach function or qname of the tpqlocate function. A char of 0 for this argument specifies the application's primary queue. The queue must be attached before do this except MRQ, if MRQ is not attached, this api will attach the MRQ first
Table 1‑16 specifies the arguments and valid values that can be applied to this part of the selection_array_component_tp structure:
 
Table 1‑16 Comparison Keys
Note:
For the special case of offset "OTMQ_SOURCE", the size can be any of following values except "0".
The Order Key part contains variables described in the following table:
 
Table 1‑17 Order Key
Correlation ID
The correlation ID is a 32-byte user-defined identifier associated with a message. If OTMQ_CORRELATION_ID is supplied as the value for either the key_1_offset or key_2_offset field, the correlation ID value is used to match messages with the specified correlation ID. Since there is a single correlation ID per message, OTMQ_CORRELATION_ID should only be specified for one of the comparison keys; specifying the correlation ID for both keys results in a TPEINVAL error.
If OTMQ_CORRELATION_ID is supplied as the value for the order_offset field, messages with the specified correlation ID are returned in the order specified by the order_order field.
Sequence Number
The message sequence number is a unique value for each message. The sequence number is stored in the PSB. Applications should acquire the message sequence number from the PSB and not modify it in any way.
Note: An application may specify only one of the two keys to select by correlation identifier or by sequence number.
num_masks
Supplies the number of records in the selection array. This argument allows a minimum of 1 record to a maximum of 256 records in the selection array.
index_handle
Receives a variable containing the index handle for the selection mask as follows:
* The high-order word contains OTMQ_BY_MASK.
* The low-order word contains the index to the selection array.
The index_handle is passed as the sel_filter argument of TPQCTL in tpdeqplus, tpqgetmsga , and tpqcancelselect functions. OTMQ implementations offer up to 32767 index handles.
Return Value(s)
Upon failure, tpqsetselect() sets tperrno to one of the following values.
[TPEINVAL]
Invalid arguments were given.
[TPENOENT]
Cannot access the qspace because it is not available.
[TPETIME]
This error code indicates that either a timeout has occurred.
[TPESYSTEM]
An Oracle Tuxedo system error has occurred. The exact nature of the error is written to a log file.
[TPEOS]
An operating system error has occurred.
tpqcancelselect()
Name
tpqcancelselect()—Releases the selection array and index handle associated with a previously generated selection mask.
Synopsis
#include <atmi.h>
#include <tmqentry.h>
#include <tmqreturn.h>
int tpqcancelselect (index_handle)
Description
Releases the selection array and index handle associated with a previously generated selection mask. An index_handle and associated selection mask are created using the tpqsetselect function. When the selection mask is used with asynchronous read requests, this function also cancels any pending tpqgetmsga requests that use the referenced index_handle.
To use tpqcancelselect(), you must first invoke tpqattach().
Table 1‑18 lists supported tpqcancelselect() arguments:
 
index_handle
Returned by tpqsetselect.
Return Value(s)
Upon failure, tpqcancelselect() sets tperrno to one of the following values.
[TPEINVAL]
Invalid arguments were given.
[TPENOENT]
Cannot access the qspace because it is not available.
[TPETIME]
This error code indicates that either a timeout has occurred.
[TPESYSTEM]
An Oracle Tuxedo system error has occurred. The exact nature of the error is written to a log file.
[TPEOS]
An operating system error has occurred
tpqreadjrn()
Name
tpqreadjrn()—Reads a message from an OTMQ local group journal.
Synopsis
#include <atmi.h>
#include <tmqentry.h>
#include <tmqreturn.h>
int tpqreadjrn (qspace, qname, ctl, type, odata, olen, timeout)
Description
Reads a message from an OTMQ journal. Before using tpqreadjrn, you must first invoke tpqattach().
Table 1‑19 lists supported tpqreadjrn arguments:
 
qspace
Supplies the queue space name as the filter to read the journal messages.
For SAF/DLQ/DLJ journal queue, queue space is the source queue space of the journal message that the client wants to read. For PCJ/DQF journal, queue space is the target queue space of the journal message that the client wants to read.
qname
Supplies the name of the permanent queue as the filter to read journal message.
For SAF/DLQ/DLJ journal queue, the queue name is the source queue of the journal messages that the client wants to read. For PCJ/DQF journal, queue name is the target queue name of the journal messages that the client wants to read
Control Parameter
flags
For tpqreadjrn(), ctl->flags must contain OTMQ| TPQREADJRN.
type
Supplies the type of the journal to read. The values only be validate as:
SAF_HANDLE
DQF_HANDLE
DLQ_HANDLE
DLJ_HANDLE
PCJ_HANDLE
odata
Receives the contents of the message retrieved from the selected message recovery journal. This argument contains either the name of a memory region or a message handle where OTMQ writes.
Olen
Supplies the size of the buffer (in bytes) for messages
timeout
Supplies the maximum amount of time the tpqreadjrn function waits for a message to arrive before returning control to the application. If the timeout occurs before a message arrives, the status code OTMQ_TIMEOUT is returned. Specifying 0 as the timeout value sets the timeout to the default value of 30 seconds.
Return Value(s)
Upon failure, tpqreadjrn() sets tperrno to one of the following values. Otherwise, the successfully read messages when tpqreadjrn() returns. you can use tpqerrno() and tpqstrerror() to get the detail OTMQ error number and detail string error message
[TPEINVAL]
Invalid arguments were given.
[TPENOENT]
Cannot access the qspace because it is not available.
[TPEOTYPE]
Either the type and subtype of the dequeued message are not known to the caller; or, TPNOCHANGE was set in flags and the type and subtype of *data do not match the type and subtype of the dequeued message. In either case, *data, its contents, and *len are not changed. When the call is made in transaction mode and this error occurs, the transaction is marked abort-only, and the message remains on the queue.
[TPETIME]
This error code indicates that either a timeout has occurred.
[TPEBLOCK]
A blocking condition exists and TPNOBLOCK was specified.
[TPGOTSIG]
A signal was received and TPSIGRSTRT was not specified.
[TPEPROTO]
tpdeqplus() was called improperly. There is no effect on the queue or the transaction.
[TPESYSTEM]
An Oracle Tuxedo system error has occurred. The exact nature of the error is written to a log file. There is no effect on the queue.
[TPEOS]
An operating system error has occurred. There is no effect on the queue.
[TPEDIAGNOSTIC]
Dequeuing a message from the specified queue failed. The reason for failure can be determined by the diagnostic value returned via ctl structure.
Diagnostic:
The following diagnostic values are returned during the dequeuing of a message:
[QMEINVAL]
An invalid flag value was specified.
[QMEBADRMID]
An invalid resource manager identifier was specified.
[QMESYSTEM]
A system error has occurred. The exact nature of the error is written to a log file.
[QMEOS]
An operating system error has occurred.
[QMEABORTED]
The operation was aborted. When executed within a global transaction, the global transaction has been marked rollback-only. Otherwise, the queue manager aborted the operation.
[QMEPROTO]
A dequeue was done when the transaction state was not active.
[QMEBADQUEUE]
An invalid or deleted queue name was specified.
[QMENOMSG]
No message was available for dequeuing. Note that it is possible that the message exists on the queue and another application process has read the message from the queue. In this case, the message may be put back on the queue if that other process rolls back the transaction.
[QMBADPRIORITY]
Invalid priority value used for receive.
[QMNOTDCL]
Process has not been attached to OTMQ.
tpqshowpending()
Name
tpqshowpending()—Requests the number of pending messages for a list of selected queues.
Synopsis
#include <atmi.h>
#include <tmqentry.h>
#include <tmqreturn.h>
int tpqshowpending ( qspace, count, in_q_list, out_pend_list)
need to follow the style of others API
Description
Requests the number of pending messages for a list of selected queues. To use the tpqshowpending function, specify the number of message queues for which you want to obtain a pending message count and the list of queue names for which you want to obtain a pending message count. The value returned by this function contains the total number of messages in each queue.
To use tpqshowpending(), you must first invoke tpqattach().
Notes:
You must allocate the out_pend_list array.

The number of queue that need to be listed is depend on "count", you must insure the array of queue list is properly allocated.
Table 1‑20 lists supported tpqshowpending()arguments.
 
qspace
Supplies the queue space name for enqueue the message. The max length is 15
count
Supplies the number of queue entries in the in_q_list argument (the number of indexes in the array). The maximum allowed value is 32,000.
In_q_list
Supplies an array containing the queue name for which the pending message count is requested
Out_pend_list
Receives the pending message count for each selected queue.
Return Value(s)
Upon failure, tpqshowpending() sets tperrno to one of the following values.You can use tpqerrno() and tpqstrerror() to get the detail OTMQ error number and detail string error message
[TPEINVAL]
Invalid arguments were given.
[TPENOENT]
Cannot access the qspace because it is not available.
[TPETIME]
This error code indicates that either a timeout has occurred.
[TPESYSTEM]
An Oracle Tuxedo system error has occurred. The exact nature of the error is written to a log file.
[TPEOS]
An operating system error has occurred.
tpqgetmsga()
Name
tpqgetmsga()—Requests asynchronous notification of a message arrival.
Synopsis
#include <atmi.h>
#include <tmqentry.h>
#include <tmqreturn.h>
int tpqgetmsga (qspace, qname, ctl, data, len , uact, uact_param , uflag, flags)
Description
Requests asynchronous notification of a message arrival. In OTMQ, the tpqgetmsga function is implemented using unsolicited message of Tuxedo. When calling tpqgetmsga, it registers its own UNSOL message handler. When a message arrives in that queue that fits the selection condition of tpqgetmsga, the message being dequeued will be sent through an UNSOL message to the application. Also if an UNSOL message has arrived, if the application setup its own message handling callback function, or an flag, the user callback function will be called, or the flag will be set to "1", to inform the application that an message has been dequeued by tpqgetmsga.
Since UNSOL message is the infrastructure of tpqgetmsga, to call this API, user must NOT set the NOTIFY to "IGNORE" in UBB. Also for some limitation, "SIGNAL" of notification mode is not supported on OpenVMS.
If a queue has been sent a recoverable message, the receiver program can confirm receipt of the message using the tpqconfirmmsg function. The tpqconfirmmsg function enables the successfully delivered message to be deleted from the message recovery system.
To use tpqgetmsga(), you must first invoke tpqattach().
Table 1‑21 lists supported tpqgetmsga() arguments:
 
qspace
Supplies the queue space name for enqueue the message. The max length is 15
qname
Supplies the queue name for enqueue the message, the max length is 127
ctl
The TPQCTL structure
data
For static buffer-style messaging, receives the name of a memory region where OTMQ writes the contents of the retrieved message.
len
Supplies the size of the buffer (in bytes) for static message buffers.
uact
user action
uact_param
user action parameters
uflag
Supplies the int value for the flag number to be set when the tpqgetmsga function completes. When the tpqgetmsga function executes, it clears this flag. If this argument value is not supplied, no flag is used.
flags
The flags supported by tpdeqplus must be set as TPNOTIME
Return Value(s)
Upon failure, tpqgetmsga() returns -1 and sets tperrno to indicate the error condition. you can use tpqerrno() and tpqstrerror() to get the detail OTMQ error number and detail string error message.
tpqgetmsga() sets tperrno to one of the following values upon failure. (Unless otherwise noted, failure does not affect caller transaction, if one exists.)
[TPEINVAL]
Invalid arguments were given.
[TPENOENT]
Cannot access the qspace because it is not available.
[TPETIME]
This error code indicates that either a timeout has occurred.
[TPESYSTEM]
An Oracle Tuxedo system error has occurred. The exact nature of the error is written to a log file. There is no effect on the queue.
[TPEOS]
An operating system error has occurred. There is no effect on the queue.
[TPEDIAGNOSTIC]
Dequeuing a message from the specified queue failed. The reason for failure can be determined by the diagnostic value returned via ctl structure.
Diagnostic:
The following diagnostic values are returned during the dequeuing of a message:
[QMEINVAL]
An invalid flag value was specified.
[QMEBADRMID]
An invalid resource manager identifier was specified.
[QMENOTOPEN]
The resource manager is not currently open.
[QMEBADMSGID]
An invalid message identifier was specified for dequeuing.
[QMESYSTEM]
A system error has occurred. The exact nature of the error is written to a log file.
[QMEOS]
An operating system error has occurred.
[QMEABORTED]
The operation was aborted. When executed within a global transaction, the global transaction has been marked rollback-only. Otherwise, the queue manager aborted the operation.
[QMEPROTO]
A dequeue was done when the transaction state was not active.
[QMEBADQUEUE]
An invalid or deleted queue name was specified.
[QMENOMSG]
No message was available for dequeuing. Note that it is possible that the message exists on the queue and another application process has read the message from the queue. In this case, the message may be put back on the queue if that other process rolls back the transaction.
[QMBADPRIORITY]
Invalid priority value used for receive.
[QMNOTDCL]
Process has not been attached to OTMQ.
tpqcancelget()
Name
tpqcancelget()—Cancels all pending tpqgetmsga requests that match the value specified in the sel_filter argument.
Synopsis
#include <atmi.h>
#include <tmqentry.h>
#include <tmqreturn.h>
int tpqcancelget (qspace, sel_filter , flags)
Description
Cancels all pending tpqgetmsga requests that match the value specified in the sel_filter argument. When a pending tpqgetmsga request is canceled, the OTMQ Status Block (PSB) delivery status is set to OTMQ__CANCEL and the specified action routine is queued. The tpqcancelget function waits until completion to allow for proper synchronization between the tpqcancelget function and the request for tpqgetmsga functions.
Any outstanding tpqgetmsga function requests are canceled by the tpqexit function or at image exit.
To use tpqcancelget(), must first invoke tpqattach().
Notes:
tpqcancelget with "sel_filter" being set as (OTMQ_PQ_PRI | x) CANNOT cancel those tpqgetmsga which set "priority" to x and "sel_filter" set to NULL.
Table 1‑22 lists supported tpqcancelget() arguments:
 
qspace
Supplies the queue space whose requests asynchronous notification of a message arrival.
sel_filter
Supplies the criteria that enables the application to selectively cancel outstanding tpqgetmsga requests. For a description of the sel_filter argument, see the tpdeqplus function. For a description of how to create a complex selection filter, see the tpqsetselect function.
Flags
If tpqcancelget() is within a transaction and the TPNOTRAN flag is not set, the api goes into transaction mode.
The following is a list of valid flags:
TPNOTRAN
If the caller is in transaction mode and this flag is set, then the event publishing is not made on behalf of the caller's transaction. A caller in transaction mode that sets this flag is still subject to the transaction timeout (and no other) when posting events. If the event posting fails, the caller's transaction is not affected.
TPNOREPLY
Informs tpqcancelget () not to wait for the EventBroker to process all subscriptions for topic before returning. When TPNOREPLY is set, regardless of whether tpqpublish() returns successfully or not. When the caller is in transaction mode, this setting cannot be used unless TPNOTRAN is also set.
TPNOBLOCK
The topic is not published if a blocking condition exists. If such a condition occurs, the call fails and tperrno is set to TPEBLOCK. When TPNOBLOCK is not specified and a blocking condition exists, the caller blocks until the condition subsides or a timeout occurs (either transaction or blocking timeout).
TPNOTIME
This flag signifies that the caller is willing to block indefinitely and wants to be immune to blocking timeouts. Transaction timeouts may still occur.
Return Value(s)
Upon failure, tpqcancelget() returns -1 and sets tperrno to indicate the error condition. You can use tpqerrno() and tpqstrerror() to get the detail OTMQ error number and detail string error message
tpqcancelget () sets tperrno to one of the following values upon failure.
[TPEINVAL]
Invalid arguments were given.
[TPENOENT]
Cannot access the qspace because it is not available.
[TPETIME]
This error code indicates that either a timeout has occurred.
[TPESYSTEM]
An Oracle Tuxedo system error has occurred. The exact nature of the error is written to a log file.
[TPEOS]
An operating system error has occurred.
tpqerrno()
Name
tpqerrno()—Gets OTMQ system call errno.
Synopsis
#include <atmi.h>
#include <tmqentry.h>
#include <tmqreturn.h>
Int tpqerrno(void);
Description
tpqerrno() is used to retrieve the error code of OTMQ system call.
Return Value(s)
Upon success, tpqstrerror() returns a pointer to a string that contains the error message text.
If err is an invalid error code, tpqstrerror() returns a NULL.
tpqexit()
Name
tpqexit()—Terminates all attachments between the application and the OTMQ queue service.
Synopsis
#include <atmi.h>
#include <tmqentry.h>
#include <tmqreturn.h>
int tpqexit(void);
Description
Terminates all attachments between the application and the OTMQ queue service. All pending messages in queues which are not unlimited and multi-resource queues are discarded. To retain messages in permanently active queues, call tpdetachq with option TUXMSGQ_NOFLUSH_Q before calling tpexitq.
Return Value(s)
Upon failure, tpqcancelget() returns -1 and sets tperrno to indicate the error condition.
[TPEPROTO]
tpqexit() was called improperly.
[TPESYSTEM]
An Oracle Tuxedo system error has occurred. The exact nature of the error is written to a log file. There is no effect on the queue.
[TPESVCERR]
A service routine encountered an error in tpqexit. If either SVCTIMEOUT in the UBBCONFIG file or TA_SVCTIMEOUT in the TM_MIB is non-zero, TPESVCERR is returned when a service timeout occurs.
tpqstrerror()
Name
tpqstrerror()—Gets Oracle Tuxedo Message Queue error message string details.
Synopsis
#include <atmi.h>
#include <tmqentry.h>
#include <tmqreturn.h>
Void tpqstrerror(int tpqerrno);
Description
tpqstrerror() is used to retrieve the text of an error message from TMQ_CAT. err is the error code set in tperrno when an OTMQ system function call returns a -1 or other failure value.
You can use the pointer returned by tpqstrerror() as an argument to userlog() or the UNIX function fprintf().
Table 1‑23 lists tpqstrerror()supported arguments:
 
tpqerrno()
Gets OTMQ system call errno.
Return Value(s)
Upon success, tpqstrerror() returns a pointer to a string that contains the error message text.
If err is an invalid error code, tpqstrerror() returns a char *.

Copyright © 1994, 2017, Oracle and/or its affiliates. All rights reserved.