Oracle8i Application Developer's Guide - Advanced Queuing Release 2 (8.1.6) Part Number A76938-01 |
|
Oracle Advanced Queuing by Example, 4 of 8
Caution: You may need to create queues or queue tables, or start or enable queues, for certain examples to work: |
/* Create subscriber list: */ DECLARE subscriber aq$_agent; /* Add subscribers RED and GREEN with different addresses to the suscriber list: */ BEGIN BEGIN /* Add subscriber RED that will dequeue messages from another_msg_queue queue in the same datatbase */ subscriber := aq$_agent('RED', 'another_msg_queue', NULL); DBMS_AQADM.ADD_SUBSCRIBER(queue_name => 'msg_queue_multiple', subscriber => subscriber); /* Schedule propagation from msg_queue_multiple to other queues in the same database: */ DBMS_AQADM.SCHEDULE_PROPAGATION(queue_name => 'msg_queue_multiple'); /* Add subscriber GREEN that will dequeue messages from the msg_queue queue in another database reached by the database link another_db.world */ subscriber := aq$_agent('GREEN', 'msg_queue@another_db.world', NULL); DBMS_AQADM.ADD_SUBSCRIBER(queue_name => 'msg_queue_multiple', subscriber => subscriber); /* Schedule propagation from msg_queue_multiple to other queues in the database "another_database": */ END; BEGIN DBMS_AQADM.SCHEDULE_PROPAGATION(queue_name => 'msg_queue_multiple', destination => 'another_db.world'); END; END; DECLARE enqueue_options DBMS_AQ.enqueue_options_t; message_properties DBMS_AQ.message_properties_t; recipients DBMS_AQ.aq$_recipient_list_t; message_handle RAW(16); message aq.message_typ; /* Enqueue MESSAGE 1 for subscribers to the queue i.e. for RED at address another_msg_queue and GREEN at address msg_ queue@another_db.world: */ BEGIN message := message_typ('MESSAGE 1', 'This message is queued for queue subscribers.'); DBMS_AQ.ENQUEUE(queue_name => 'msg_queue_multiple', enqueue_options => enqueue_options, message_properties => message_properties, payload => message, msgid => message_handle); /* Enqueue MESSAGE 2 for specified recipients i.e. for RED at address another_msg_queue and BLUE.*/ message := message_typ('MESSAGE 2', 'This message is queued for two recipients.'); recipients(1) := aq$_agent('RED', 'another_msg_queue', NULL); recipients(2) := aq$_agent('BLUE', NULL, NULL); message_properties.recipient_list := recipients; DBMS_AQ.ENQUEUE(queue_name => 'msg_queue_multiple', enqueue_options => enqueue_options, message_properties => message_properties, payload => message, msgid => message_handle); COMMIT; END;
/* Schedule propagation from queue q1def to other queues in the same database */ EXECUTE DBMS_AQADM.SCHEDULE_PROPAGATION(queue_name => 'q1def'); /* Disable propagation from queue q1def to other queues in the same database */ EXECUTE DBMS_AQADM.DISABLE_PROPAGATION_SCHEDULE( queue_name => 'q1def'); /* Alter schedule from queue q1def to other queues in the same database */ EXECUTE DBMS_AQADM.ALTER_PROPAGATION_SCHEDULE( queue_name => 'q1def', duration => '2000', next_time => 'SYSDATE + 3600/86400', latency => '32'); /* Enable propagation from queue q1def to other queues in the same database */ EXECUTE DBMS_AQADM.ENABLE_PROPAGATION_SCHEDULE( queue_name => 'q1def'); /* Unschedule propagation from queue q1def to other queues in the same database */ EXECUTE DBMS_AQADM.UNSCHEDULE_PROPAGATION( queue_name => 'q1def');
/* Schedule propagation from queue q1def to other queues in another database reached by the database link another_db.world */ EXECUTE DBMS_AQADM.SCHEDULE_PROPAGATION( queue_name => 'q1def', destination => 'another_db.world'); /* Disable propagation from queue q1def to other queues in another database reached by the database link another_db.world */ EXECUTE DBMS_AQADM.DISABLE_PROPAGATION_SCHEDULE( queue_name => 'q1def', destination => 'another_db.world'); /* Alter schedule from queue q1def to other queues in another database reached by the database link another_db.world */ EXECUTE DBMS_AQADM.ALTER_PROPAGATION_SCHEDULE( queue_name => 'q1def', destination => 'another_db.world', duration => '2000', next_time => 'SYSDATE + 3600/86400', latency => '32'); /* Enable propagation from queue q1def to other queues in another database reached by the database link another_db.world */ EXECUTE DBMS_AQADM.ENABLE_PROPAGATION_SCHEDULE( queue_name => 'q1def', destination => 'another_db.world'); /* Unschedule propagation from queue q1def to other queues in another database reached by the database link another_db.world */ EXECUTE DBMS_AQADM.UNSCHEDULE_PROPAGATION( queue_name => 'q1def', destination => 'another_db.world');
/* Unschedule propagation from msg_queue_multiple to the destination another_ db.world */ EXECUTE DBMS_AQADM.UNSCHEDULE_PROPAGATION( queue_name => 'msg_queue_multiple', destination => 'another_db.world');
|
![]() Copyright © 1996-2000, Oracle Corporation. All Rights Reserved. |
|