![]() | Programming Guide | ![]() |
Subscribes to an event managed by the Oracle Tuxedo event broker
subscribe EVENTeventNameNOTIFICATIONnotificationSpecENQUEUEenqueueSpec[OUTSIDE_TRANSACTION] [PERSIST]
[FILTERrule] [NOTIMEOUT]
EVENTeventName- The name of an event.
eventNameis any regular expression containing up to 255 characters. For information about regular expressions, refer torecomp() in the Oracle Tuxedo Reference Manual.NOTIFICATIONnotificationSpec- Method of notification to the subscriber when the event is posted, formatted as follows:
{SERVICEserviceName| ENQUEUEenqueueSpec}
SERVICEserviceName- Notification is done via a call to the service
serviceName. The event broker callsserviceNameto notify the agent of the event.ENQUEUEenqueueSpec- Notification is done via enqueuing a message to a reliable queue.
enqueueSpechas this format:QSPACEqueueSpaceNAMEqueueName[queueOption[queueOption]...]
QSPACEqueueSpace- The name of the queue space to which the queue belongs.
NAMEqueueName- The name of the queue.
queueOption- One or more of the enqueuing options listed in the "Enqueue Options" section.
OUTSIDE_TRANSACTION- Specifies that event notifications are dispatched outside of the current transaction. If this option is not used, the default behavior is notification within the current transaction.
PERSIST- Maintains the event subscription regardless of any error situation. By default, subscriptions are deleted when a resource is not available to an event poster.
FILTERrule- A filter rule to apply when the event broker determines that the subscriber should be notified of an event. rule is a string expression of up to 255 characters. The rule is applied to the message data of the event posting. This option is available for
FMLandSTRINGtypes only.NOTIMEOUT- Specify that the execution of this command is unaffected by the blocking timeout.
BEFORE_MSGIDmsgId—Put the message ahead of the message with Oracle Tuxedo message identifiermsgId.
The server dequeues the message and calls the appropriate service, if it is monitoring the queue.
dequeueTimecan be a relative time (time elapsed after the message is enqueued) or an absolute time. An absolute time must be greater than January 1 1970 00:00:00 UTC. In either case, Panther can dequeue the command only after the specified amount of time has elapsed.
A relativedequeueTimecan be specified in this format:"[ +dayshours::minutes::]seconds"Seconds are required; minutes, hours, or days (space delimiter between days and hours) can also be specified. If more than seconds is specified, the + symbol and the quotation marks are mandatory. If only seconds are specified, both are optional.
Note: JPL's colon preprocessor expands colon-prefixed variables. To prevent expansion of variables that contain colons, prefix literal colons with another colon (
::) or a backslash (\:).An absolute
dequeueTimecan be specified in one of these ways:
- The value from a widget having Date/Time property values.
FAILUREQqueue| NOFAILUREQ—Specify a failure queue to which failure responses can be enqueued, or useNOFAILUREQif no failure message is necessary. If this option is not used, the JIF is checked for a failure queue.
Oracle Tuxedo
Client, Server
The
subscribecommand permits agents to subscribe to events managed by the event broker. Once an event is posted via the post command, subscribers to the event are notified in the manner determined by the arguments to this command.When the subscribing agent is a client, event notification is done via an unsolicited message. A client can receive unsolicited notifications only if it has appropriate message handling. Refer to the client_init and receive commands for information on how to permit clients to receive unsolicited messages.
For servers subscribing to events, there are two methods of notification: notification by service call and notification by message queuing.
Before notification is initiated, the event broker, after successfully matching the event to its potential subscribers via the
EVENTeventName, applies the subscribers filter rule if one was used. If the data passes through the filter rule, the subscriber is notified via the method selected withnotificationSpec.Successful execution of the subscribe command results in a unique subscription ID, which can be accessed from the
tp_returnproperty. If the command fails,tp_returnis set toTP_FAILURE.For additional information on message queuing, refer to "Reliable Queues" in JetNet/Oracle Tuxedo Guide and refer to your Oracle Tuxedo System /Q documentation.
The filter rule is contained in a string of up to 255 characters. The rule format is specific to the type of event message data—
FMLorSTRING—of the event's data to which it is applied.
FMLfilters can be built from primary expressions, regular expressions, and operators. ASTRINGfilter must be in the form of a regular expression. For information about regular expressions, refer torecomp() in the Oracle Tuxedo Reference Manual; for information about operators and primary expressions, refer to the Oracle Tuxedo FML Guide.
Because
subscribeuses message queues, it can raise some of the same exceptions as theenqueuecommand.
// Client
// The client will receive an unsolicited message
// along with any data posted with the event.subscribe EVENT "user*" FILTER "*something*"// Server
// The server will receive notification via a call
// to the service "svc1"subscribe EVENT "user*" FILTER "*something" \
NOTIFICATION SERVICE "svc1" OUTSIDE_TRANSACTION// Server
// The server will receive notification via enqueuing the
// message to the queue "queue1" in queue space "qspace1."subscribe EVENT "user*" NOTIFICATION ENQUEUE QSPACE \
"qspace1" NAME "queue1" PRIORITY 5 REPLYQ "rqueue1" NOTIMEOUT
enqueue, dequeue, post, unsubscribe
![]()
![]()
![]()
![]()