Oracle8i Application Developer's Guide - Advanced Queuing Release 8.1.5 A68005-01 |
|
In this chapter we describe the administrative interface to Oracle Advanced Queuing in terms of use cases. That is, we discuss each operation (such as "Create a Queue Table") as a use case by that name. The table listing all the use cases is provided at the head of the chapter (see "Use Case Model: Administrative Interface -- Basic Operations").
A summary figure, "Use Case Diagram: Administrator's Interface -- Basic Operations", locates all the use cases in single drawing. If you are using the HTML version of this document, you can use this figure to navigate to the use case in which you are interested by clicking on the relevant use case title.
The individual use cases are themselves laid out as follows:
Use Case |
---|
Create a queue table for messages of a pre-defined type. The sort keys for dequeue ordering, if any, need to be defined at table creation time. The following objects are created at this time:
aq$_<queue_table_name>_e.
aq$<queue_table_name>.
aq$_<queue_table_name>_t
.
aq$_<queue_table_name>_i.
For 8.1-compatible multiconsumer queue tables the following additional objects are created:
aq$_<queue_table_name>_s.
This table stores information about the subscribers.
aq$_<queue_table_name>_r.
This table stores information about rules on subscriptions.
aq$_<queue_table_name>_h.
This table stores the dequeue history data.
DBMS_AQADM.CREATE_QUEUE_TABLE (queue_table IN VARCHAR2, queue_payload_type IN VARCHAR2, storage_clause IN VARCHAR2 default NULL, sort_list IN VARCHAR2 default NULL, multiple_consumers IN BOOLEAN default FALSE, message_grouping IN BINARY_INTEGER default NONE, comment IN VARCHAR2 default NULL, auto_commit IN BOOLEAN default TRUE,primary_instance IN BINARY_INTEGER default 0, secondary_instance IN BINARY_INTEGER default 0, compatible IN VARCHAR2 default '8.0');
Parameter | Description |
---|---|
|
specifies the name of a queue table to be created. |
|
specifies the type of the user data stored. Please see section entitled "Type name" for valid values for this parameter. |
|
specifies the storage parameter. The storage parameter will be included in the '
If tablespace is not specified in the Please refer to the SQL reference guide for the usage of these parameters. |
|
specifies the columns to be used as the sort key in ascending order. Sort_list has the following format: '<sort_column_1>,<sort_column_2>'. The allowed column names are priority and enq_time. If both columns are specified then <sort_column_1> defines the most significant order. Once a queue table is created with a specific ordering mechanism, all queues in the queue table inherit the same defaults. The order of a queue table cannot be altered once the queue table has been created. If no sort list is specified all the queues in this queue table will be sorted by the enqueue time in ascending order. This order is equivalent to FIFO order. Even with the default ordering defined, a dequeuer is allowed to choose a message to dequeue by specifying its msgid or correlation. Msgid, correlation and sequence_deviation take precedence over the default dequeueing order if they are specified. |
|
|
|
specifies the message grouping behavior for queues created in the table.
|
|
specifies the user-specified description of the queue table. This user comment will be added to the queue catalog. |
|
Caution: This parameter has been deprecated. |
|
This is the primary owner of the queue table. Queue monitor scheduling and propagation for the queues in the queue table will be done in this instance.
The default value for primary instance is |
|
The queue table fails over to the secondary instance if the primary instance is not available. The default value is |
|
specifies the lowest database version with which the queue is compatible. Currently the possible values are either '8.0' or '8.1'. The default is '8.0'. |
CLOB
, BLOB
or BFILE
objects are valid attributes for an AQ object type load. However, only CLOB and BLOB can be propagated using AQ propagation in Oracle8i release 8.1.x.
primary_instance
and secondary_instance
only when the database is in 8.1-compatible mode.
CREATE type aq.Message_typ as object ( Subject VARCHAR2(30), Text VARCHAR2(80)); /* Note: if you do not stipulate a schema, you default to the user's schema. */ EXECUTE dbms_aqadm.create_queue_table ( Queue_table => 'aq.ObjMsgs_qtab', Queue_payload_type => 'aq.Message_typ');
EXECUTE dbms_aqadm.create_queue_table ( Queue_table => 'aq.RawMsgs_qtab', Queue_payload_type => 'RAW');
EXECUTE dbms_aqadm.create_queue_table ( Queue_table => 'aq.PriorityMsgs_qtab', Sort_list => 'PRIORITY,ENQ_TIME', Queue_payload_type => 'aq.Message_typ');
EXECUTE dbms_aqadm.create_queue_table ( Queue_table => 'aq.MultiConsumerMsgs_qtab', Multiple_consumers => TRUE, Queue_payload_type => 'aq.Message_typ');
EXECUTE dbms_aqadm.create_queue_table ( Queue_table => 'aq.Multiconsumermsgs8_1qtab', Multiple_consumers => TRUE, Compatible => '8.1', Queue_payload_type => 'aq.Message_typ');
EXECUTE dbms_aqadm.create_queue_table( queue_table => 'aq.aq_tbsMsg_qtab', queue_payload_type => 'aq.Message_typ', storage_clause => 'tablespace aq_tbs');
Alter the existing properties of a queue table.
DBMS_AQADM.ALTER_QUEUE_TABLE ( queue_table IN VARCHAR2, comment IN VARCHAR2 default NULL, primary_instance IN BINARY_INTEGER default NULL, secondary_instance IN BINARY_INTEGER default NULL);
/* Altering the table to change the primary, secondary instances for queue owner (only applicable for OPS environments).The primary instance is the instance number of the primary owner of the queue table. The secondary instance is the instance number of the secondary owner of the queue table. */ EXECUTE dbms_aqadm.alter_queue_table ( Queue_table => 'aq.ObjMsgs_qtab', Primary_instance => 3, Secondary_instance => 2); /* Altering the table to change the comment for a queue table: */ EXECUTE dbms_aqadm.alter_queue_table ( Queue_table => 'aq.ObjMsgs_qtab', Comment => 'revised usage for queue table');
Drop an existing queue table. Note that you must stop and drop all the queues in a queue tables before the queue table can be dropped. You must do this explicitly unless the force
option is used in which case this done automatically.
DBMS_AQADM.DROP_QUEUE_TABLE ( queue_table IN VARCHAR2, force IN BOOLEAN default FALSE, auto_commit IN BOOLEAN default TRUE);
/* Drop the queue table (for which all queues have been previously dropped by the user) */ EXECUTE dbms_aqadm.drop_queue_table ( queue_table => 'aq.Objmsgs_qtab');
/* Drop the queue table and force all queues to be stopped and dropped by the system */ EXECUTE dbms_aqadm.drop_queue_table ( queue_table => 'aq.Objmsgs_qtab', force => TRUE);
Create a queue in the specified queue table.
DBMS_AQADM.CREATE_QUEUE ( queue_name IN VARCHAR2, queue_table IN VARCHAR2, queue_type IN BINARY_INTEGER default NORMAL_QUEUE, max_retries IN NUMBER default NULL, retry_delay IN NUMBER default 0, retention_time IN NUMBER default 0, dependency_tracking IN BOOLEAN default FALSE, comment IN VARCHAR2 default NULL, auto_commit IN BOOLEAN default TRUE);
Parameter | Description |
---|---|
|
specifies the name of the queue that is to be created. The name must be unique within a schema and must follow object name guidelines in the Oracle8i SQL Reference with regard to reserved characters. |
|
specifies the name of the queue table that will contain the queue. |
|
specifies whether the queue being created is an exception queue or a normal queue.
|
|
limits the number of times a dequeue with the |
|
specifies the delay time, in seconds before this message is scheduled for processing again after an application rollback. The default is 0, which means the message can be retried as soon as possible. This parameter will have no effect if |
|
specifies the number of seconds for which a message will be retained in the queue table after being dequeued from the queue.
number: Number of seconds for which to retain the messages. The default is 0, i.e. no retention. |
|
|
|
User-specified description of the queue. This user comment will be added to the queue catalog. |
|
Caution: This parameter has been deprecated. |
CREATE_QUEUE
, it can be enabled by calling START_QUEUE
. By default, the queue is created with both enqueue and dequeue disabled.
/* Create a message type: */ CREATE type aq.Message_typ as object ( Subject VARCHAR2(30), Text VARCHAR2(80)); /* Create a object type queue table and queue: */ EXECUTE dbms_aqadm.create_queue_table ( Queue_table => 'aq.ObjMsgs_qtab', Queue_payload_type => 'aq.Message_typ'); EXECUTE dbms_aqadm.create_queue ( Queue_name => 'msg_queue', Queue_table => 'aq.ObjMsgs_qtab');
/* Create a RAW type queue table and queue: */ EXECUTE dbms_aqadm.create_queue_table ( Queue_table => 'aq.RawMsgs_qtab', Queue_payload_type => 'RAW'); /* Create queue: */ EXECUTE dbms_aqadm.create_queue ( Queue_name => 'raw_msg_queue', Queue_table => 'aq.RawMsgs_qtab');
/* Create a queue table for priortized messages: */ EXECUTE dbms_aqadm.create_queue_table ( Queue_table => 'aq.PriorityMsgs_qtab', Sort_list => 'PRIORITY,ENQ_TIME', Queue_payload_type => 'aq.Message_typ'); /* Create queue: */ EXECUTE dbms_aqadm.create_queue ( Queue_name => 'priority_msg_queue', Queue_table => 'aq.PriorityMsgs_qtab');
/* Create a queue table for multi-consumers: */ EXECUTE dbms_aqadm.create_queue_table ( queue_table => 'aq.MultiConsumerMsgs_qtab', Multiple_consumers => TRUE, Queue_payload_type => 'aq.Message_typ'); /* Create queue: */ EXECUTE dbms_aqadm.create_queue ( Queue_name => 'MultiConsumerMsg_queue', Queue_table => 'aq.MultiConsumerMsgs_qtab');
/* Create queue: */ EXECUTE dbms_aqadm.create_queue ( Queue_name => 'AnotherMsg_queue', queue_table => 'aq.MultiConsumerMsgs_qtab');
/* Create a queue table for multi-consumers compatible with Release 8.1: */ EXECUTE dbms_aqadm.create_queue_table ( Queue_table => 'aq.MultiConsumerMsgs81_qtab', Multiple_consumers => TRUE, Compatible => '8.1', Queue_payload_type => 'aq.Message_typ'); EXECUTE dbms_aqadm.create_queue ( Queue_name => 'MultiConsumerMsg81_queue', Queue_table => 'aq.MultiConsumerMsgs81_qtab');
Create a non-persistent RAW
queue.
DBMS_AQADM.CREATE_NP_QUEUE ( queue_name IN VARCHAR2, multiple_consumers IN BOOLEAN default FALSE, comment IN VARCHAR2 default NULL);
Parameter | Description |
---|---|
|
specifies the name of the non-persistent queue that is to be created. The name must be unique within a schema and must follow object name guidelines in the Oracle8i SQL Reference with regard to reserved characters. |
|
Note that the |
|
User-specified description of the queue. This user comment will be added to the queue catalog. |
AQ$_MEM_SC
or AQ$_MEM_MC
) in the same schema as that specified by the queue name. If the queue name does not specify a schema name, the queue is created in the login user's schema. Once a queue is created with CREATE_NP_QUEUE
, it can be enabled by calling START_QUEUE
. By default, the queue is created with both enqueue and dequeue disabled.
listen
call on a non-persistent queue (see Listen to One (Many) Queue(s)).
/* Create a non-persistent single-consumer queue (Note: this is not preceded by creation of a queue table) */ EXECUTE dbms_aqadm.create_np_queue( Queue_name => 'Singleconsumersmsg_npque', Multiple_consumers => FALSE); /* Create a non-persistent multi-consumer queue (Note: this is not preceded by creation of a queue table) */ EXECUTE dbms_aqadm.create_np_queue( Queue_name => 'Multiconsumersmsg_npque', Multiple_consumers => TRUE);
Alter existing properties of a queue. Only max_retries, retry_delay, and retention_time can be altered.
DBMS_AQADM.ALTER_QUEUE ( queue_name IN VARCHAR2, max_retries IN NUMBER default NULL, retry_delay IN NUMBER default NULL, retention_time IN NUMBER default NULL, auto_commit IN BOOLEAN default TRUE, comment IN VARCHAR2 default NULL);
Table 4-7 DBMS_AQADM.ALTER_QUEUE
max_retries
, retention
, retry_delay
and retry_count
are not supported for non-persistent queues.
/* Alter queue to change retention time, saving messages for 1 day after dequeueing: */ EXECUTE dbms_aqadm.alter_queue ( queue_name => 'aq.Anothermsg_queue', retention_time => 86400);
Drops an existing queue. DROP_QUEUE
is not allowed unless STOP_QUEUE
has been called to disable the queue for both enqueuing and dequeuing. All the queue data is deleted as part of the drop operation.
DBMS_AQADM.DROP_QUEUE ( queue_name IN VARCHAR2, auto_commit IN BOOLEAN default TRUE);
/* Stop the queue preparatory to dropping it (a queue may be dropped only after it has been succesfully stopped for enqueing and dequeing): */ EXECUTE dbms_aqadm.stop_queue ( Queue_name => 'aq.Msg_queue'); /* Drop queue: */ EXECUTE dbms_aqadm.drop_queue ( Queue_name => 'aq.Msg_queue');
EXECUTE DBMS_AQADM.DROP_QUEUE( queue_name => 'Nonpersistent_ singleconsumerq1'); EXECUTE DBMS_AQADM.DROP_QUEUE( queue_name => 'Nonpersistent_multiconsumerq1');
Enables the specified queue for enqueuing and/or dequeueing.
DBMS_AQADM.START_QUEUE ( queue_name IN VARCHAR2, enqueue IN BOOLEAN default TRUE, dequeue IN BOOLEAN default TRUE)
After creating a queue the administrator must use START_QUEUE
to enable the queue. The default is to enable it for both ENQUEUE
and DEQUEUE
. Only dequeue operations are allowed on an exception queue. This operation takes effect when the call completes and does not have any transactional characteristics.
/* Start a queue and enable both enqueue and dequeue: */ EXECUTE dbms_aqadm.start_queue ( queue_name => 'Msg_queue');/* Start a previously stopped queue for dequeue only */ EXECUTE dbms_aqadm.start_queue ( queue_name => 'aq.msg_queue', dequeue => TRUE, enqueue => FALSE);
Disables enqueuing and/or dequeuing on the specified queue.
DBMS_AQADM.STOP_QUEUE ( queue_name IN VARCHAR2, enqueue IN BOOLEAN default TRUE, dequeue IN BOOLEAN default TRUE, wait IN BOOLEAN default TRUE);
By default, this call disables both ENQUEUE
s or DEQUEUE
s. A queue cannot be stopped if there are outstanding transactions against the queue. This operation takes effect when the call completes and does not have any transactional characteristics.
/* Stop the queue: */ EXECUTE dbms_aqadm.stop_queue ( queue_name => 'aq.Msg_queue');
To grant AQ system privileges to users and roles. The privileges are ENQUEUE_ANY
, DEQUEUE_ANY
, MANAGE_ANY
. Initially, only SYS
and SYSTEM
can use this procedure successfully.
DBMS_AQADM.GRANT_SYSTEM_PRIVILEGE( privilege IN VARCHAR2, grantee IN VARCHAR2, admin_option IN BOOLEAN := FALSE);
/* User AQADM grants the rights to enqueue and dequeue to ANY queues: */
CONNECT aqadm/aqadm; EXECUTE DBMS_AQADM.GRANT_SYSTEM_PRIVILEGE( privilege => 'ENQUEUE_ANY', grantee => 'Jones', admin_option => FALSE); EXECUTE DBMS_AQADM.GRANT_SYSTEM_PRIVILEGE( privilege => 'DEQUEUE_ANY', grantee => 'Jones', admin_option => FALSE);
To revoke AQ system privileges from users and roles. The privileges are ENQUEUE_ANY
, DEQUEUE_ANY
and MANAGE_ANY
. The ADMIN
option for a system privilege cannot be selectively revoked.
DBMS_AQADM.REVOKE_SYSTEM_PRIVILEGE( privilege IN VARCHAR2, grantee IN VARCHAR2);
/* To revoke the DEQUEUE_ANY system privilege from Jones. */ CONNECT system/manager; execute DBMS_AQADM.REVOKE_SYSTEM_PRIVILEGE(privilege=>'DEQUEUE_ANY', grantee=>'Jones');
To grant privileges on a queue to users and roles. The privileges are ENQUEUE
or DEQUEUE
. Initially, only the queue table owner can use this procedure to grant privileges on the queues.
DBMS_AQADM.GRANT_QUEUE_PRIVILEGE( privilege IN VARCHAR2, queue_name IN VARCHAR2, grantee IN VARCHAR2, grant_option IN BOOLEAN := FALSE);
/* User grants the access right for both enqueue and dequeue rights using DBMS_AQADM.GRANT. */ EXECUTE DBMS_AQADM.GRANT_QUEUE_PRIVILEGE ( privilege => 'ALL', queue_name => 'aq.multiconsumermsg81_queue', grantee => 'Jones', grant_option => TRUE);
To revoke privileges on a queue from users and roles. The privileges are ENQUEUE
or DEQUEUE
.
DBMS_AQADM.REVOKE_QUEUE_PRIVILEGE( privilege IN VARCHAR2, queue_name IN VARCHAR2, grantee IN VARCHAR2);
To revoke a privilege, the revoker must be the original grantor of the privilege. The privileges propagated through the GRANT
option are revoked if the grantor's privileges are revoked.
/* User can revoke the dequeue right of a grantee on a specific queue leaving the grantee with only the enqueue right: */ CONNECT scott/tiger; EXECUTE DBMS_AQADM.REVOKE_QUEUE_PRIVILEGE( privilege => 'DEQUEUE', queue_name => 'scott.ScottMsgs_queue', grantee => 'Jones');
Adds a default subscriber to a queue.
DBMS_AQADM.ADD_SUBSCRIBER( queue_name IN VARCHAR2, subscriber IN aq$_agent, rule IN VARCHAR2 default NULL);
Parameter | Description |
---|---|
|
specifies the name of the queue. |
|
The agent on whose behalf the subscription is being defined (see definition of "Agent"). |
|
A conditional expression based on the message properties, the message data properties and PL/SQL functions. A rule is specified as a boolean expression using syntax similar to the |
rule => 'PRIORITY <= 3 AND CORRID = ''FROM JAPAN'''
Note that these are all single quotation marks.
/* Anonymous PL/SQL block for adding a subscriber at a designated queue in a designated schema at a database link: */ DECLARE subscriber aq$_agent; BEGIN subscriber := aq$_agent ('subscriber1', 'aq2.msg_queue2@london', null); DBMS_AQADM.ADD_SUBSCRIBER( queue_name => 'aq.multi_queue', subscriber => subscriber); END; /* Add a subscriber with a rule: */ DECLARE subscriber aq$_agent; BEGIN subscriber := aq$_agent('subscriber2', 'aq2.msg_queue2@london', null); DBMS_AQADM.ADD_SUBSCRIBER( queue_name => 'aq.multi_queue', subscriber => subscriber, rule => 'priority < 2'); END;
DECLARE subscriber aq$_agent; BEGIN subscriber := aq$_agent('East_Shipping','ES.ES_bookedorders_que',null); DBMS_AQADM.ADD_SUBSCRIBER( queue_name => 'OE.OE_bookedorders_que', subscriber => subscriber, rule => 'tab.user_data.orderregion = ''EASTERN'' OR (tab.user_data.ordertype = ''RUSH'' AND tab.user_data.customer.country = ''USA'') '); END;
Alter existing properties of a subscriber to a specified queue. Only the rule can be altered.
DBMS_AQADM.ALTER_SUBSCRIBER( queue_name IN VARCHAR2, subscriber IN aq$_agent rule IN VARCHAR2);
Parameter | Description |
---|---|
|
specifies the name of the queue. |
|
The agent on whose behalf the subscription is being altered (see definition of "Agent"). |
|
A conditional expression based on the message properties, the message data properties and PL/SQL functions.The rule parameter cannot exceed 4000 characters.To eliminate the rule, set the rule parameter to |
/* Add a subscriber with a rule: */ DECLARE subscriber aq$_agent; BEGIN subscriber := aq$_agent('SUBSCRIBER1', 'aq2.msg_queue2@london', null); DBMS_AQADM.ADD_SUBSCRIBER( queue_name => 'aq.msg_queue', subscriber => subscriber, rule => 'priority < 2'); END; /* Change rule for subscriber: */ DECLARE subscriber aq$_agent; BEGIN subscriber := aq$_agent('SUBSCRIBER1', 'aq2.msg_queue2@london', null); DBMS_AQADM.ALTER_SUBSCRIBER( queue_name => 'aq.msg_queue', subscriber => subscriber, rule => 'priority = 1'); END;
Remove a default subscriber from a queue.
DBMS_AQADM.REMOVE_SUBSCRIBER( queue_name IN VARCHAR2, subscriber IN aq$_agent);
Parameter | Description |
---|---|
|
specifies the name of the queue. |
|
The agent who is being removed from the (see definition of "Agent"). |
This operation takes effect immediately and the containing transaction is committed. All references to the subscriber in existing messages are removed as part of the operation.
DECLARE subscriber aq$_agent; BEGIN subscriber := aq$_agent('subscriber1','aq2.msg_queue2', NULL); DBMS_AQADM.REMOVE_SUBSCRIBER( queue_name => 'aq.multi_queue', subscriber => subscriber); END;
Schedule propagation of messages from a queue to a destination identified by a specific dblink.
DBMS_AQADM.SCHEDULE_PROPAGATION( queue_name IN VARCHAR2, destination IN VARCHAR2 default NULL, start_time IN DATE default SYSDATE, duration IN NUMBER default NULL, next_time IN VARCHAR2 default NULL, latency IN NUMBER default 60);
Messages may also be propagated to other queues in the same database by specifying a NULL
destination. If a message has multiple recipients at the same destination in either the same or different queues the message will be propagated to all of them at the same time.
/* Schedule propagation from queue aq.q1def
to other queues in the same
database */
EXECUTE DBMS_AQADM.SCHEDULE_PROPAGATION(
Queue_name => 'aq.q1def');
/* Schedule a propagation from queue aq.q1def to other queues in another database */ EXECUTE DBMS_AQADM.SCHEDULE_PROPAGATION( Queue_name => 'aq.q1def', Destination => 'another_db.world');
Unschedule a previously scheduled propagation of messages from a queue to a destination identified by a specific dblink
.
DBMS_AQADM.UNSCHEDULE_PROPAGATION( queue_name IN VARCHAR2, destination IN VARCHAR2 default NULL);
/* Unschedule propagation from queue aq.q1def to other queues in the same database: */ EXECUTE DBMS_AQADM.UNSCHEDULE_PROPAGATION(queue_name => 'aq.q1def');
/* Unschedule propagation from queueaq.q1def
to other queues in another database reached by the database linkanother_db.world
*/ EXECUTE DBMS_AQADM.UNSCHEDULE_PROPAGATION( Queue_name => 'aq.q1def', Destination => 'another_db.world');
Verify that the source and destination queues have identical types. The result of the verification is stored in aq$_Message_types tables
, overwriting all previous output of this command.
DBMS_AQADM.VERIFY_QUEUE_TYPES( src_queue_name IN VARCHAR2, dest_queue_name IN VARCHAR2, destination IN VARCHAR2 default NULL, rc OUT BINARY_INTEGER);
/* Verify if the source and destination queues have the same type. The function has the side effect of inserting/updating the entry for the source and destination queues in the dictionary table AQ$_MESSAGE_TYPES */ DECLARE rc BINARY_INTEGER; BEGIN /* Verify if the queues aq.q1def and aq.q2def in the local database have the same payload type */ DBMS_AQADM.VERIFY_QUEUE_TYPES( src_queue_name => 'aq.q1def', dest_queue_name => 'aq.q2def', rc => rc); DBMS_OUTPUT.PUT_LINE(rc); END;
To alter parameters for a propagation schedule.
DBMS_AQADM.ALTER_PROPAGATION_SCHEDULE ( queue_name IN VARCHAR2, destination IN VARCHAR2 default NULL, duration IN NUMBER default NULL, next_time IN VARCHAR2 default NULL, latency IN NUMBER default 60);
/* Alter schedule from queue aq.q1def to other queues in the same database */ EXECUTE DBMS_AQADM.ALTER_PROPAGATION_SCHEDULE( Queue_name => 'aq.q1def', Duration => '2000', Next_time => 'SYSDATE + 3600/86400', Latency => '32');
/* Alter schedule from queue aq.q1def
to other queues in another database
reached by the database link another_db.world */
EXECUTE DBMS_AQADM.ALTER_PROPAGATION_SCHEDULE(
Queue_name => 'aq.q1def',
Destination => 'another_db.world',
Duration => '2000',
Next_time => 'SYSDATE + 3600/86400',
Latency => '32');
To enable a previously disabled propagation schedule.
DBMS_AQADM.ENABLE_PROPAGATION_SCHEDULE ( queue_name IN VARCHAR2, destination IN VARCHAR2 default NULL);
/* Enable propagation from queue aq.q1def to other queues in the same database */ EXECUTE DBMS_AQADM.ENABLE_PROPAGATION_SCHEDULE( Queue_name => 'aq.q1def');
/* Enable propagation from queue aq.q1def to other queues in another database reached by the database link another_db.world */ EXECUTE DBMS_AQADM.ENABLE_PROPAGATION_SCHEDULE( Queue_name => 'aq.q1def', Destination => 'another_db.world');
To disable a previously disabled propagation schedule.
DBMS_AQADM.DISABLE_PROPAGATION_SCHEDULE ( queue_name IN VARCHAR2, destination IN VARCHAR2 default NULL);
/* Disable a propagation from queue aq.q1def to other queues in the same database */ EXECUTE DBMS_AQADM.DISABLE_PROPAGATION_SCHEDULE( Queue_name => 'aq.q1def');
/* Disable a propagation from queue aq.q1def to other queues in another database reached by the database link another_db.world */ EXECUTE DBMS_AQADM.DISABLE_PROPAGATION_SCHEDULE( Queue_name => 'aq.q1def', Destination => 'another_db.world');
This section describes some troubleshooting tips to diagnose problems with message propagation.
AQ updates the message history when a message has been successfully propagated to a destination. The message history is stored as a collection in the queue table. An administrator can execute a SQL query to determine if a message has been propagated. For example, to check if a message with msgid
105E7A2EBFF11348E03400400B40F149
'
in queue table aqadmn.queue_tab
has been propagated to destination 'boston
', the following query can be executed:
SELECT consumer, transaction_id, deq_time, deq_user, propagated_msgid FROM THE(select cast(history as aq$_dequeue_history_t) FROM adadmn.queue_tab WHERE msgid='105E7A2EBFF11348E03400400B40F149') WHERE consumer LIKE '%BOSTON%';
A non-NULL transaction_id
indicates that the message was successfully propagated. Further, the deq_time
indicates the time of propagation, the deq_user
indicates the userid used for propagation, and the propagated_msgid
indicates the msgid of the message that was enqueued at the destination. If the message with the msgid cannot be found in the queue table, an administrator can check the exception queue (if the exception queue is in a different queue table) for the message history.
To verify that propagation is working successfully, examine the schedule information using the DBA_QUEUE_SCHEDULES
view. Check the error message field to discover if any error occurred during propagation. If there was an error, the error time and error date field display when the error last occurred. After you have corrected the problem, propagation should resume.
You should also determine if the schedule has been disabled (DISABLED
field is Y
). Propagation should resume once you have enabled the schedule by invoking ENABLE_PROPAGATION_SCHEDULE
. If the schedule is already enabled, check if the schedule is active. A schedule is active if a PROCESS_NAME
exists for that schedule. If one does not exist, which means that the schedule is inactive, check the time of the last successful execution and when the schedule will be next executed. If the next scheduled execution is too far away, change the NEXT_TIME
parameter of the schedule so that schedules are executed more frequently (assuming that the window is not set to be infinite).
Parameters of a schedule can be changed using the ALTER_PROPAGATION_SCHEDULE
call. If a schedule is active then the source queue may not have any messages to be propagated.
There are a number of points at which propagation may break down:
dbms_aqadm.schedule_propagation
) has access to the database link for the destination.
aq$_agent
type (in the subscriber list for the source queue or in the recipient list of the enqueuer) both (a) exists at the specified destination, and (b) has been enabled for enqueuing. All these and other errors that the propagator encounters are logged into trace file(s) generated by the job_queue processes in $ORACLE_HOME/
log directory.
AQ will not propagate messages from one queue to another if the payload-types of the two queues are not equivalent. An administrator can verify if the source and destination's payload types match by executing the DBMS_AQADM.VERIFY_QUEUE_TYPES
procedure. The results of the type checking will be stored in the aq$_message_types table. This table can be accessed using the OID
of the source queue and the address of the destination queue (i.e. [schema.]queue_name[@destination
]).