Introducing PL/SQL applications for Advanced Queuing
Describe the prebuilt PL/SQL Packages used to create an Advanced Queuing Application
PL/SQL prebuilt Package Applications for Queuing
Oracle comes with a number of prebuilt PL/SQL packages that you use to implement Advanced Queuing.
The two basic packages are called DBMS_AQ and DBMS_AQADM. During the rest of this module, as you create your own sample advanced queuing application, you will be using many of the
procedures contained in these packages.
The DBMS_AQ package contains the basic procedures necessary to use queues. These procedures are:
ENQUEUE: To add a message to a queue
DEQUEUE: To take a message from a queue
LISTEN: To wait on one or more queues for the arrival of incoming messages on behalf of an agent
The DBMS_AQ package also includes type definitions, such as object names, agents, and recipient, agent, and subscriber lists, for most of the objects needed to uses queues. Type definition: Defines an Oracle8i object type.
The DBMS_AQADM package contains procedures to administer queues. These procedures include:
CREATE_/ALTER_/DROP_QUEUEs: To manage queues
CREATE_/ALTER_/DROP_QUEUE_TABLE: To manage queue tables
START_/STOP_QUEUE: To control the operation of a queue
GRANT_/REVOKE_QUEU_PRIVILEGE: To control security on a queue
ADD_/ALTER_/REMOVE_SUBSCRIBER: To manage subscribers to a queue
SCHEDULE_/UNSCHEDULE_PROPAGATION: To control the propagation of messages from a queue
ENABLE_/DISABLE_ALTER_PROPAGATION_SCHEDULE: To control the schedule of the propagation of messages from a queue
This procedure sets the queue where the apply process automatically enqueues a message that satisfies the specified rule. This procedure modifies the specified rule's action context to specify the queue. A rule action context is optional information associated with a rule that is interpreted by the client of the rules engine after the rule evaluates to TRUE for a message.
In this case, the client of the rules engine is an Oracle Streams apply process. The information in an action context is an object of type SYS.RE$NV_LIST, which consists of a list of name-value pairs. A queue destination specified by this procedure always consists of the following
name-value pair in an action context:
The name is APPLY$_ENQUEUE.
The value is a ANYDATA instance containing the queue name specified as a
rule_name IN VARCHAR2,
destination_queue_name IN VARCHAR2);
If an apply handler, such as a DML handler, DDL handler, or message handler, processes a message that also is enqueued into a destination queue, then the apply handler processes the message before it is enqueued.
The following are considerations for using this procedure:
This procedure does not verify that the specified queue exists. If the queue does
not exist, then an error is raised when an apply process tries to enqueue a message
Oracle Streams capture processes, propagations, and messaging clients ignore the action context created by this procedure.
The apply user of the apply processes using the specified rule must have the
necessary privileges to enqueue messages into the specified queue. If the queue is
a secure queue, then the apply user must be a secure queue user of the queue.
The specified rule must be in the positive rule set for an apply process. If the rule is in the negative rule set for an apply process, then the apply process does not enqueue the message into the destination queue.
If the commit SCN for a message is less than or equal to the relevant instantiation
SCN for the message, then the message is not enqueued into the destination
queue, even if the message satisfies the apply process rule sets.
In the next lesson, you will start to build a sample application that uses Advanced Queuing.
Package: A group of PL/SQL procedures that are combined into a single logical grouping. The package header contains the interface description for the procedures, whereas the package body contains the actual code for the procedures in the package.
Procedure: Uses PL/SQL code and syntax to implement a logical operation.