且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Oracle Advance Queue-出队不起作用

更新时间:2023-02-16 14:58:43

创建代码块并运行以下代码:

Create a code block and run the following:

DECLARE
  dequeue_options      DBMS_AQ.dequeue_options_t;
  message_properties   DBMS_AQ.message_properties_t;
  message_handle       RAW (16);
  I_PAYLOAD            ITEM_EVENT;
  no_messages exception;
  msg_content          VARCHAR2 (4000);
  PRAGMA EXCEPTION_INIT (no_messages, -25228);
BEGIN
  dequeue_options.wait := DBMS_AQ.NO_WAIT;
  dequeue_options.consumer_name := 'ITEM_SUBSCRIBER_1';   
  dequeue_options.navigation := DBMS_AQ.FIRST_MESSAGE;
LOOP    
 DBMS_AQ.DEQUEUE (queue_name           => 'ITEM_EVENT_QUEUE',
                      dequeue_options      => dequeue_options,
                      message_properties   => message_properties,
                      payload              => I_PAYLOAD,
                      msgid                => message_handle
                     );
END LOOP;
  EXCEPTION
  WHEN no_messages
  THEN
     DBMS_OUTPUT.PUT_LINE ('No more messages left');
END;

让我知道您排队的邮件会发生什么情况.

Let me know what happens to your enqueued messages.

您应该有一个要在其中使用数据的表.

You should have a table where you're dequing the data.

您是否还可以尝试在代理中添加入队表,然后将代理指定到出队表中.

Can you also try adding the enqueud table in the agent and then specify the agent to the dequeue table.

DECLARE
  aSubscriber sys.aq$_agent;
BEGIN 
  aSubscriber := sys.aq$_agent('ITEM_SUBSCRIBER_1',
                          'ITEM_EVENT_QUEUE',
                          0);
  dbms_aqadm.add_subscriber
 ( queue_name     => 'ITEM_EVENT_QUEUE'
  ,subscriber     => aSubscriber);
END;
/