oracle-databaseadvanced-queuing

Can't DELETE message from Oracle Advanced exception Queue


I have an exception advanced queue with 3 messages, for example. If I try to dequeue them it works fine, but in my application, I need to delete some of them by MSGID. I tried it using SQL commands, but it delays a lot and then I get timeout.

Advanced Queue:

CREATE_QUEUE_TABLE (
   queue_table            => 'AQUSER.event_message_queue_qt',
   queue_payload_type     => 'AQUSER.EventMessageType',
   sort_list              => 'ENQ_TIME, PRIORITY');

CREATE_QUEUE (
  queue_name => 'AQUSER.event_message_queue', 
  queue_table => 'AQUSER.event_message_queue_qt',
  max_retries=> 10,
  retry_delay=> 600);

CREATE_QUEUE ( 
  queue_name              => 'AQUSER.event_message_queue_ex_q', 
  queue_table             => 'AQUSER.event_message_queue_qt', 
  queue_type              => DBMS_AQADM.EXCEPTION_QUEUE);

Trying to delete by MSGID:

select * from event_message_queue_qt
where Q_NAME = 'event_message_queue_ex_q'
and MSGID = '6AA2E0C9A14ABA97E053119A14333514'

Solution

  • The advanced queue table was locked by other users but I didn't get a nice message about it.

    I ran the following command to figure out that:

    select 
       (select username from v$session where sid=a.sid) blocker,
       a.sid,
       ' is blocking ',
       (select username from v$session where sid=b.sid) blockee,
       b.sid
    from v$lock a, v$lock b
    where a.block = 1
    and b.request > 0
    and a.id1 = b.id1
    and a.id2 = b.id2;