Oracle Advance Queue - Dequeue not working

*爱你&永不变心* 提交于 2019-11-30 14:42:11

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;
/

I faced the same problem, but it was solved after changing these 2 DB parameters:

  1. job_queue_processes (must be > than 0)
  2. aq_tm_processes (autotuning)

Hope it helps.

We faced a related problem (at least related to the title), we couldn't dequeue messages with a delay. The messages in the queue stayed the state "WAITING". And were not changed to "READY".

The Oracle AQ monitoring process that is responsable for changing the state from "WAITING" to "READY" (after the delay is expired) wasn't working properly.

For us a database restart fixed this issue.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!