Solved

Oracle AQ Queue clogged with expired messages

Posted on 2009-05-13
4
3,705 Views
Last Modified: 2013-12-07
I have an application that uses Oracle AQ. We have a queue that has accumulated more than 5 million expired messages. One option is to drop and create the queue again but it seems to take a very long time. Can some one suggest alternate options?
0
Comment
Question by:rjha
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 13

Expert Comment

by:anand_2000v
ID: 24386865
Dequeue from Exception queue

Exception Queues

An exception queue is a repository for expired or unserviceable messages. Applications cannot directly enqueue into exception queues. Also, a multiconsumer exception queue cannot have subscribers associated with it. However, an application that intends to handle these expired or unserviceable messages can dequeue them exactly once from the exception queue using remove mode. The consumer name specified while dequeuing should be null. Messages can also be dequeued from the exception queue by specifying the message identifier.

Refer:http://download.oracle.com/docs/cd/B19306_01/server.102/b14257/aq_intro.htm
0
 

Accepted Solution

by:
rjha earned 0 total points
ID: 24571501
Hi,

I have been able to get a solution for this issue. I am posting the details below:

1. 'START' the exception queue and allow dequeueing on it
BEGIN
  SYS.DBMS_AQADM.START_QUEUE
  (
    QUEUE_NAME => 'exception queue name'
   ,ENQUEUE => FALSE
   ,DEQUEUE => TRUE
   );
END;
/

2. Then use a PL/SQL block like one below to read expired messages from the exception queue:

DECLARE
  l_dequeue_options     DBMS_AQ.dequeue_options_t;
  l_message_properties  DBMS_AQ.message_properties_t;
  l_message_handle      RAW(16);
  l_event_msg           <event payload type>;
  cursor c_exp_mesg is
  select MSG_ID
  from <queue table name>
  where msg_state = 'EXPIRED';
BEGIN
  l_dequeue_options.consumer_name := null;
  for rec in c_exp_mesg
  LOOP
      l_dequeue_options.msgid  := rec.msg_id;
      DBMS_AQ.dequeue(queue_name          => 'exception queue name',
                      dequeue_options     => l_dequeue_options,
                      message_properties  => l_message_properties,
                      payload             => l_event_msg,
                      msgid               => l_message_handle);
    -- process your message here in whatever way you want..

END;
/
0
 

Author Comment

by:rjha
ID: 24571534
Hi,

I have posted the solution that worked for me. Please do not delete this question but you can mark the solution provided as the accepted solution as it worked for me and can be helpful for others facing a similar issue.

Thanks,
Raj
0

Featured Post

Database Solutions Engineer FAQs

In this series, we will discuss common questions received as a database Solutions Engineer at Percona. In this role, we speak with a wide array of MySQL and MongoDB users responsible for both extremely large and complex environments to smaller single-server environments.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This post first appeared at Oracleinaction  (http://oracleinaction.com/undo-and-redo-in-oracle/)by Anju Garg (Myself). I  will demonstrate that undo for DML’s is stored both in undo tablespace and online redo logs. Then, we will analyze the reaso…
Shell script to create broker configuration file using current broker Configuration, solely for purpose of backup on Linux. Script may need to be modified depending on OS-installation. Please deploy and verify the script in a test environment.
Via a live example, show how to restore a database from backup after a simulated disk failure using RMAN.
This video explains what a user managed backup is and shows how to take one, providing a couple of simple example scripts.

617 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question