5

编辑:这似乎与将两个队列放在同一个模式中有关。

我正在尝试尝试队列传播,但在目标队列中没有看到记录。但这很可能是因为我没有准备好所有的部分。

有人有可以发布的测试用例吗?我将在下面包含我尝试过的内容。我发现文档中的故障排除有点轻,传播是如此的黑匣子,很难知道为什么它没有移动。

这就是我所拥有的;没有笑。


CREATE OR REPLACE TYPE test_payload AS OBJECT(
   test_id   NUMBER,
   test_dt   DATE);


DECLARE
   subscriber   SYS.aq$_agent;
BEGIN
--- Create Originating Queue and start it

   DBMS_AQADM.create_queue_table( queue_table => 'Test_MQT', queue_payload_type => 'Test_Payload',
                                  multiple_consumers => TRUE ); --- multiple subscriber 

   DBMS_AQADM.create_queue( 'Test_Q', 'Test_MQT' );
   DBMS_AQADM.start_queue( queue_name => 'Test_Q' );

--- Create Destination Queue and start it

   DBMS_AQADM.create_queue_table( queue_table => 'Dest_MQT', queue_payload_type => 'Test_Payload',
                                  multiple_consumers => TRUE );
   DBMS_AQADM.create_queue( 'Dest_Q', 'Dest_MQT' );
   DBMS_AQADM.start_queue( queue_name => 'Dest_Q' );

--- Add Subscriber and schedule propagation

   subscriber := SYS.aq$_agent( 'test_local_sub', 'Dest_Q', NULL );
   DBMS_AQADM.add_subscriber( queue_name => 'Test_Q', subscriber => subscriber );
   DBMS_AQADM.schedule_propagation( queue_name => 'Test_Q', destination_queue => 'Dest_Q' );
END;

DECLARE
   enqueue_options      DBMS_AQ.enqueue_options_t;
   message_properties   DBMS_AQ.message_properties_t;
   message_handle       RAW( 16 );
   MESSAGE              test_payload;
BEGIN
   MESSAGE := test_payload( 2, SYSDATE );
   DBMS_AQ.enqueue( queue_name => 'Test_Q', enqueue_options => enqueue_options,
                    message_properties => message_properties, payload => MESSAGE, msgid => message_handle );
   COMMIT;
END;

DECLARE
   dequeue_options      DBMS_AQ.dequeue_options_t;
   message_properties   DBMS_AQ.message_properties_t;
   message_handle       RAW( 16 );
   MESSAGE              test_payload;
BEGIN
   dequeue_options.navigation := DBMS_AQ.first_message;
   DBMS_AQ.dequeue( queue_name => 'Dest_Q', dequeue_options => dequeue_options,
                    message_properties => message_properties, payload => MESSAGE, msgid => message_handle );
   DBMS_OUTPUT.put_line( 'Test_ID: ' || MESSAGE.test_id );
   DBMS_OUTPUT.put_line( 'Test_Date: ' || MESSAGE.test_dt );
   COMMIT;
END;
4

3 回答 3

1

也许您需要启用它?

DBMS_AQADM.ENABLE_PROPAGATION_SCHEDULE(queue_name => 'Test_Q'); 
于 2008-10-18T14:20:24.607 回答
0

您可能想通过 AQ 上的 Tom Kyte 线程阅读:

http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:8760267539329#tom1246632800346467977

于 2008-10-20T02:57:21.927 回答
0

您需要有一个默认订阅者到传播的目标队列。需要有一些东西来倾听

于 2008-10-30T16:56:40.893 回答