1 Oracle Tuxedo /Q Overview
This topic includes the following sections:
1.1 General Description
The Oracle Tuxedo /Q component enables messages to be queued for processing or retrieval after they have been stored on persistent disk or non-persistent memory. The Oracle Tuxedo Application-to-Transaction Monitor Interface (ATMI) provides functions that enable messages to be added to or read from queues. A reply message and an error message can be queued for later retrieval by the client program. The administrative command interpreter enables the creation, listing, and modification of servers. Message queue servers accept requests to enqueue and dequeue messages, forward messages from the queue for processing, and manage transactions that involve queues.
Parent topic: Oracle Tuxedo /Q Overview
1.2 Queuing System Components and Tasks
The following figure illustrates the components of the queued message facility.
Figure 1-1 Queued Service Invocation

The figure illustrates how each component of the queuing system operates during the invocation of queued services. This discussion utilizes the figure to illustrate how administrators and programmers interact with Oracle Tuxedo /Q. A queued message is queued for processing and a reply is returned to the sender. You can also use the queuing service for peer-to-peer communication by integrating a subset of the components illustrated in the figure. A queue space is a resource. Access to the resource is provided by an X/OPEN XA-compliant resource manager interface. A two-phase committed transaction involving this interface enables enqueuing and dequeuing to be performed in coordination with other XA-compliant resource managers.
Parent topic: Oracle Tuxedo /Q Overview
1.3 Administrator Tasks
The Oracle Tuxedo administrator is responsible for defining servers and creating queue spaces and queues like those shown between the vertical dashed lines in the figure Queued Service Invocation. The administrator must define at least one queue server group with TMS_QM
as the transaction manager server for the group.
Two additional system-provided servers must be defined in the configuration file. These servers perform the following functions:
- The message queue server,TMQUEUE(5), is used to enqueue and dequeue messages. This provides a surrogate server for doing message operations for clients and servers, whether or not they are local to the queue.
- TMQFORWARD(5) is a message-forwarding server that dequeues and forwards messages to application servers. Oracle Tuxedo provides the main() function for servers, which handles initialization and termination of the server, allocates buffers to receive and dispatch incoming requests, and routes replies appropriately. All of this processing is transparent to the application. Existing servers do not dequeue their messages or enqueue replies. Oracle Tuxedo /Q is designed to enable existing servers to serve queued messages without requiring any modification. The TMQFORWARD server dequeues a message from one or more queues in the queue space, forwards the message to a server with a service that is named the same as the queue, waits for the reply, and queues the successful reply or failure reply on the associated reply or failure queues, respectively, as specified by the originator of the message (if the originator specified a reply or failure queue).
The administrator must also create a queue space by using either the queue administration program, qmadmin(1), or the APPQ_MIB(5) Management Information Base (MIB). The queue space contains a collection of queues. In the figure Queued Service Invocation, for example, the APP queue space contains four queues. Each queue space corresponds to a single resource manager (RM), and a group can only have one RM.
The notion of queue space enables reducing the administrative overhead associated with a queue by sharing the overhead among a collection of queues in the following ways:
- The queues in a queue space share persistent and non-persistent storage areas for messages.
- A single message queue server, TMQUEUE in the figure Queued Service Invocation, can be used to enqueue and dequeue messages for multiple queues within a single queue space.
- A single message forwarding server, TMQFORWARD in the figure Queued Service Invocation, can be used to dequeue and forward messages to services from multiple queues within a single queue space.
- In the figure Queued Service Invocation, two instances of the transaction manager server, TMS_QM, are shown. This enables transactions to be completed across multiple queues within the same queue space. The first transaction manager server instance is reserved for non-blocking transactions in order to ensure that they are processed as quickly as possible without being slowed down by blocking transactions. The second instance of the transaction manager server is responsible for handling blocking transactions.
The administrator can define a single server group in the application configuration for the queue space by specifying the group in UBBCONFIG or by using tmconfig(1) to add the group dynamically.
- Finally, when the administrator moves messages between queues within a queue space, the overhead is less than if the messages were in different stable storage areas, because a one-phase commit can be done.
Part of the task of defining a queue is specifying the order for messages on the queue. Queue ordering can be determined by message availability time, expiration time, priority, FIFO, LIFO, or a combination of these criteria.
The administrator specifies one or more of these sort criteria for the queue, listing the most significant criteria first. The FIFO and LIFO values must be the least significant sort criteria. Messages are put on the queue according to the specified sort criteria and dequeued from the top of the queue. The administrator can configure as many message queuing servers as required to keep up with the requests generated by clients for the stable queues.
A data-dependent routing approach can enable routing between servers in multiple groups offering the same service.
For housekeeping purposes, the administrator can set up a command to be executed when a threshold is reached for a queue that does not routinely get drained. This can be based on the bytes, blocks, or percentage of the queue space used by the queue or the number of messages on the queue. The command might boot a TMQFORWARD server to drain the queue or send mail to the administrator for manual handling.
The Oracle Tuxedo system uses the Queuing Services component of the Oracle Tuxedo infrastructure for some operations. (The Oracle Tuxedo infrastructure provides services such as security, scalability, message queuing, and transactions.) For example, administrative operations for shared memory are provided by the Queuing Services component. Some functions are not currently applicable to Oracle Tuxedo applications; this is noted in descriptions of these functions.
You can also use the queued message facility for peer-to-peer communication between clients, such that a client communicates with other clients without using any forwarding server. The peer-to-peer communication model is depicted in the following figure.
Figure 1-2 Peer-to-Peer Communication

See Also:
TMQUEUE(5)
,TMQFORWARD(5)
,APPQ_MIB(5)
in the Section 5 - File Formats, Data Descriptions, MIBs, and System Processes Reference.tmconfig
,wtmconfig(1)
in the Section 1- Commands.
Parent topic: Oracle Tuxedo /Q Overview
1.4 Programmer Tasks
Following the instructions in steps 1 to 3 of the figure Queued Service Invocation, a client enqueues a message to the SERVICE1
queue in the APP queue space using tpenqueue(3c). An optional reply queue and failure queue can also be specified in the call to tpenqueue ()
. The example illustrates the queues CLIENT_REPLY1
and FAILURE_Q
. The client can specify a correlation identifier value to accompany the message. The value is persistent across queues so that it can be used to identify any reply or failure messages associated with a queued message. It is read from the reply or failure queue during this process.
There are two types of queue ordering available to the client: standard queue ordering (for example, a time after which a message should be available for dequeuing), or override the default queue ordering (requesting, for example, that this message be placed at the top or ahead of another message)).tpenqueue()
sends the message to the TMQUEUE
server, queues the message, and sends an acknowledgment (step 3) to the client; the acknowledgment is not visible to the client, however it can be assumed when the client receives a successful response. (A failure return includes information about the nature of the failure.)
A message identifier assigned by the queue manager is returned to the application. The identifier can be used to dequeue a specific message. In addition to this, tpenqueue()
can also be used to identify a message already enqueued ahead of a subsequent message.
The transaction in which a message is enqueued must be successfully completed before the message can be dequeued.
When using Oracle Tuxedo /Q for queued service invocation, and the message reaches the top of the queue, the TMQFORWARD server dequeues the message and forwards it, through tpcall(3c), to a service with the same name as the queue name. In the figure Queued Service Invocation, the queue and the service are named SERVICE1
, and steps 4, 5, and 6 in the figure show this. The client identifier and application authentication key are provided to the client responsible for enqueuing the message and accompanying the dequeued message as it is sent to the service.
When the service returns a reply, TMQFORWARD enqueues the reply (with an optional user-return code) to the reply queue (step 7 in the figure Queued Service Invocation).
Later (steps 8, 9 and 10 in the figure Queued Service Invocation), the client uses tpdequeue(3c) to retrieve the reply message from the reply queue CLIENT_REPLY1
.
You can dequeue messages without removing them from the queue, by using the TPQPEEK flag with tpdequeue()
. A message that has expired or has been deleted by an administrator is immediately removed from the queue.
See Also:
- tpenqueue(3c), tpcall(3c), and tpdequeue(3c) in the Section 3c - C Functions
- tpcall(3c) in
Parent topic: Oracle Tuxedo /Q Overview
1.4.1 Transaction Management
With regard to transaction management, one goal is to ensure reliability by enqueuing and dequeuing messages within global transactions. However, a conflicting goal is to reduce the execution overhead by minimizing the number of transactions that are involved.
An option is provided for the caller to enqueue a message outside any transaction in which the caller is involved (decoupling the queuing from the caller's transaction). However, a timeout in this situation leaves it unknown as to whether or not the message is enqueued.
A better approach is to enqueue the message within the caller's transaction, as is depicted in the following figure.
Figure 1-3 Transaction Demarcation

In the figure, the client starts a transaction, queues the message and commits the transaction. The message is dequeued within a second transaction started by TMQFORWARD; the service is called with tpcall(3c), is executed and the reply is enqueued within the same transaction. A third transaction, started by the client, is used to dequeue the reply (and possibly enqueue another request message). In ongoing processing, the third and first transactions can meld into one since enqueuing the next request can be done in the same transaction as dequeuing the response from the previous request.
Note:
The system enables you to dequeue a response from one message and enqueue the next request within the same transaction, but does not allow you to enqueue a request and dequeue the response within the same transaction. The transaction in which the request is enqueued must be successfully committed before the message is available for dequeuing.See Also:
tpcall(3c) in the Section 3c - C FunctionsParent topic: Programmer Tasks
1.4.2 Handling Reply Messages
A reply queue can be either specified or not by the application when calling tpenqueue(). The effect is as follows:
- If a reply queue is not specified for a queued message, then no further work is required beyond processing the message.
- If a message is dequeued that does specify a reply queue, then the originator of the message expects a reply to be enqueued upon successful completion of the execution of the request.
- In the case where the application explicitly dequeues the message using tpdequeue(), it is the responsibility of the application to call tpenqueue() to enqueue the reply. Normally, this would be done in the same transaction in which the request message is dequeued and executed so the entire operation is handled atomically (that is, the reply is enqueued only if the transaction succeeds).
- In the case where the message is automatically processed by a service (dequeued and passed to the application via a tpcall()) by TMQFORWARD, TMQFORWARD enqueues a reply if the application service returns successfully (that is, the service routine called tpreturn(3c) with TPSUCCESS and tpcall() did not return 1). If tpcall() receives data, then the typed buffer used is enqueued to the reply queue. If no data is received in tpcall(), then a message with no data (that is, a NULL message) is enqueued; the fact that a message is enqueued (even if NULL) is sufficient to signify that the operation has been completed.
See Also :
tpreturn(3c) in the Section 3c - C FunctionsParent topic: Programmer Tasks
1.4.3 Error Handling
Handling of errors requires both an understanding of the nature of the errors the application may encounter and careful planning and coordination between the Oracle Tuxedo administrator and the application program developers. The way Oracle Tuxedo /Q works, if a message is dequeued within a transaction and the transaction is rolled back, then (if the retry parameter is greater than 0) the message ends up back on the queue where it can be dequeued and executed again.
For a transient problem, it may be desirable to delay for a short period before retrying to dequeue and execute the message, allowing the transient problem to clear. For example, if there is a lot of activity against the application database, there may be occasions when all you need is a little time to allow locks in a database to be released by another transaction. Normally, a limit on the number of retries is also useful to ensure that some application flaw doesn't cause significant waste of resources. When a queue is configured by the administrator, both a retry count and a delay period (in seconds) can be specified. A retry count of 0 implies that no retries are done. After the retry count is reached, the message is moved to an error queue that can be configured by the administrator for the queue space.
There are cases where the problem is not transient. For example, the queued message may request operations on an account that does not exist. In this case, it is desirable not to waste any resources by trying again. If the application programmer or administrator determines that failures for a particular operation are never transient, then it is simply a matter of setting the retry count to zero. It is more likely the case that for the same service some problems will be transient and some problems will be permanent; the administrator and application developers need to have more than a single approach to handle errors.
Other variations come about because the application may either dequeue messages directly or use the TMQFORWARD server and because an error may cause a transaction to be rolled back and the message re-queued while logic dictates that the transaction should be committed. These variations and ways to deal with them are discussed in Oracle Tuxedo /Q Administration, Oracle Tuxedo /Q C Language Programming, and Oracle Tuxedo /Q COBOL Language Programming.
Parent topic: Programmer Tasks
1.4.4 Summary
To summarize, Oracle Tuxedo /Q provides the following features to Oracle Tuxedo application programmers and administrators:
- An application programming interface that lets you enqueue a request for subsequent processing. The system guarantees to execute the request successfully exactly once (by default, failure causes the message to be put back on the queue). An application programming interface is also provided to dequeue messages either from the top of a queue or by message identifier or correlation identifier.
- An application programming interface that lets you enqueue a request for subsequent processing. The system guarantees to execute the request successfully exactly once (by default, failure causes the message to be put back on the queue). An application programming interface is also provided to dequeue messages either from the top of a queue or by message identifier or correlation identifier.
- The application program and/or the administrator can control the ordering of messages on the queue. Control is via the sort criteria, which may be based on message availability time, expiration time, priority, LIFO, FIFO, or a combination of these criteria. The application can override the ordering to place the message at the queue top or ahead of a specific message that is already queued.
- An Oracle Tuxedo server is provided to enqueue and dequeue messages on behalf of, possibly remote, clients and servers. The administrator decides how many copies of the server should be configured.
- An Oracle Tuxedo server is provided to dequeue queued messages and forward them to services for execution. This server allows for existing servers to handle queued requests without modification. Each forwarding server can be configured to handle one or more queues. Transactions are used to guarantee exactly-once processing. The administrator controls how many forwarding servers are configured.
- The administrator can control messages stored on the queues for processing. This includes the number of times requests are retried on failure and how much time elapses between retries, reordering messages on queues, managing queue capacity and so on.
There are many application paradigms in which queued messages can be used. This feature can be used to queue requests when a machine, server, or resource is unavailable or unreliable (for example, in the case of a wide area or wireless networks). This feature can also be used for work flow provisioning where each step generates a queued request to do the next step in the process. Yet another use is for batch processing of potentially long running transactions, such that the initiator does not have to wait for completion but is assured that the message will eventually be processed. This facility may also be used to provide a data pipe between two otherwise unrelated applications in a peer-to-peer relationship.
Parent topic: Programmer Tasks