10.2.4.2.4 Unsolicited Messages
For each context in a multithreaded or multicontexted application, you may choose one of three methods for handling unsolicited messages.
A context may ... | By setting ... |
---|---|
Ignore unsolicited messages | TPU_IGN
|
Uses dip-in notification | TPU_DIP
|
Use dedicated thread notification. (available only for C applications) | TPU_THREAD
|
The following caveats apply:
-
SIGNAL
-based notification is not allowed in multithreaded or multicontexted processes. - If your application runs on a platform that supports multicontexting but not multithreading, then you cannot use the
TPU_THREAD
unsolicited notification method. As a result, you cannot receive immediate notification of events.If receiving immediate notification of events is important to your application, then you must carefully consider whether to use a multicontexted approach on this platform.
- Dedicated thread notification is available only:
- For applications written in C
- On multithreaded platforms supported by the Oracle Tuxedo system
When dedicated thread notification is chosen, the system dedicates a separate thread to receive unsolicited messages and dispatch the unsolicited message handler. Only one copy of the unsolicited message handler can run at any one time in a given context.
If tpinit() is called on a platform for which the Oracle Tuxedo system does not support threads, with parameters indicating that TPU_THREAD
notification is being requested on a platform that does not support threads, tpinit()
returns -1
and sets tperrno
to TPEINVAL
. If the UBBCONFIG(5) default NOTIFY
option is set to THREAD
but threads are not available on a particular machine, the default behavior for that machine is downgraded to DIPIN
. The difference between these two behaviors allows an administrator to specify a default for all machines in a mixed configuration—a configuration that includes some machines that support threads and some that do not—but it does not allow a client to explicitly request a behavior that is not available on its machine.
If tpsetunsol() is called from a thread that is not associated with a context, a per-process default unsolicited message handler for all new tpinit()
contexts created is established. A specific context may change the unsolicited message handler for that context by calling tpsetunsol()
again when the context is active. The per-process default unsolicited message handler may be changed by again calling tpsetunsol()
in a thread not currently associated with a context.
If a process has multiple associations with the same application, then each association is assigned a different CLIENTID
so that it is possible to send an unsolicited message to a specific application association. If a process has multiple associations with the same application, then any tpbroadcast() is sent separately to each of the application associations that meet the broadcast criteria. When performing a dip-in check for receiving unsolicited messages, an application checks for only those messages sent to the current application association.
In addition to the ATMI functions permitted in unsolicited message handlers, it is permissible to call tpgetctxt(3c) within an unsolicited message handler. This functionality allows an unsolicited message handler to create another thread to perform any more substantial ATMI work required within the same context.
Parent topic: Work Phase