Programming Guide |
Subscribes to an event managed by the Oracle Tuxedo event broker
subscribe EVENTeventName
NOTIFICATIONnotificationSpec
ENQUEUEenqueueSpec
[OUTSIDE_TRANSACTION] [PERSIST]
[FILTERrule
] [NOTIMEOUT]
EVENT
eventName
- The name of an event.
eventName
is any regular expression containing up to 255 characters. For information about regular expressions, refer torecomp
() in the Oracle Tuxedo Reference Manual.NOTIFICATION
notificationSpec
- Method of notification to the subscriber when the event is posted, formatted as follows:
{SERVICEserviceName
| ENQUEUEenqueueSpec
}
SERVICE
serviceName
- Notification is done via a call to the service
serviceName
. The event broker callsserviceName
to notify the agent of the event.ENQUEUE
enqueueSpec
- Notification is done via enqueuing a message to a reliable queue.
enqueueSpec
has this format:QSPACEqueueSpace
NAMEqueueName
[queueOption
[queueOption
]...]
QSPACE
queueSpace
- The name of the queue space to which the queue belongs.
NAME
queueName
- 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.
FILTER
rule
- 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
FML
andSTRING
types only.NOTIMEOUT
- Specify that the execution of this command is unaffected by the blocking timeout.
BEFORE_MSGID
msgId
—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.
dequeueTime
can 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 relativedequeueTime
can be specified in this format:"[ +days
hours
::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
dequeueTime
can be specified in one of these ways:
- The value from a widget having Date/Time property values.
FAILUREQ
queue
| NOFAILUREQ
—Specify a failure queue to which failure responses can be enqueued, or useNOFAILUREQ
if no failure message is necessary. If this option is not used, the JIF is checked for a failure queue.
Oracle Tuxedo
Client, Server
The
subscribe
command 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
EVENT
eventName
, 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_return
property. If the command fails,tp_return
is 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—
FML
orSTRING
—of the event's data to which it is applied.
FML
filters can be built from primary expressions, regular expressions, and operators. ASTRING
filter 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
subscribe
uses message queues, it can raise some of the same exceptions as theenqueue
command.
// 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