![]() | 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
.CORRID
corrID
—A correlation ID to associate with the enqueued message, a string of up to 32 characters. The value is maintained across all queues, so any reply or failure message associated with the queued message can be identified.DQTIME
dequeueTime
—Specifies when to make the message available for dequeuing. If you omit this option, the message can be dequeued immediately.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.
- A date/time string in this format:
"mm/dd/yy HH::MM"
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.FRONT
—Place the message at the head of the queue. This option can only be used if the queue has been configured (when it was created) forout_of_order
enqueuing, with this attribute set to top.- For further information on
out_of_order
enqueuing, refer to the Oracle Tuxedo /Q Guide of the Oracle Tuxedo SDK in your Oracle Tuxedo documentation.PRIORITY
priority
— Establish a priority value for the message. The valid range is 1 to 100; the default is 1. This option will only have effect if the queue was created using priority as a queue-ordering parameter. The larger the value of priority, the higher the priority.- For further information on priority enqueuing, refer to the Oracle Tuxedo /Q Guide of the Oracle Tuxedo SDK in your Oracle Tuxedo documentation.
RCODE
returnCode
—Specify an integer-value return code to be made available to the application. The return is handed to the reply queue from the service which replies to the message.REPLYQ
queue
| NOREPLYQ
—Specify a reply queue to which replies can be enqueued, or useNOREPLYQ
if no reply message is wanted. If this option is not used, the JIF is checked for a reply queue.
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.
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
![]()
![]()
![]()
![]()