Skip to Main Content
  • Questions
  • Oracle Queues getting stopped even though there are Ongoing transaction to be dequeued

Breadcrumb

Question and Answer

Chris Saxon

Thanks for the question, Sarith.

Asked: March 13, 2023 - 1:47 pm UTC

Last updated: March 16, 2023 - 12:50 pm UTC

Version: 10.2.0.5.0

Viewed 1000+ times

You Asked

Hi Tom,

Hope you had a good timeoff and not sure whether this is a silly question to ask. I did try searching on the Oracle forum but did not get any conclusive details on the wait option to be set as true or false while stopping the Oracle queue.

We have a issue in our system wherein the Java MDB server are getting stopped every 2 hours and in case any queue transaction is dequeued and in progress, a protocol violation error is raised and it is not processed further. To avoid this issue , we are looking at stopping the dequeue before restarting the server and then start the dequeue again once the server has been restarted successfully so that we don't miss out on any transactions.

Below was the command, we had used to stop the dequeuing. Even though we had around 20 plus transactions to be dequeued, system still allowed to stop the queue but the comments on oracle forum says otherwise

Wait :- Specifies whether to wait for the completion of outstanding transactions. TRUE means wait if there are any outstanding transactions. In this state no new transactions are allowed to enqueue to or dequeue from this queue. FALSE means return immediately either with a success or an error.

begin
DBMS_AQADM.STOP_QUEUE (   
   'TEST_2023_Q',
   FALSE,
   TRUE,
   TRUE);
end;


Could you please advise if there is anything wrong in my understanding or the piece of code

and Chris said...

I'm unclear exactly what the issue is here. Have you tried running this and messages continue to be dequeued long after you stop it?

The call you're making asks to stop the dequeue process, waiting for any outstanding transactions to complete.

So what exactly is the problem/error you're hitting when doing this?

Rating

  (2 ratings)

Is this answer out of date? If it is, please let us know via a Comment

Comments

Oracle Queues getting stopped even though there are Ongoing transaction to be dequeued

Sarith Sreedharan, March 15, 2023 - 1:18 pm UTC

Hi Chris,

We had some 20 transactions to be dequeued on the queue before running the given PL sql block to stop the queue.

As per the details given in Oracle forum, if the Wait option is given as TRUE, then it waits to see if there are any outstanding transactions before stopping the queue.

Wait :- Specifies whether to wait for the completion of outstanding transactions. TRUE means wait if there are any outstanding transactions. In this state no new transactions are allowed to enqueue to or dequeue from this queue. FALSE means return immediately either with a success or an error.

So can you advise why in this instance it actually allowed to stop the queue even though the existing records were not dequeued.
Chris Saxon
March 15, 2023 - 6:31 pm UTC

The answer's right there:

In this state no new transactions are allowed to enqueue to or dequeue from this queue.

Once you call this (even with wait) you can't dequeue any more messages. My understanding is WAIT => TRUE allows transactions the process of enqueuing/dequeuing messages to complete. It doesn't wait for the whole queue to be empty.

Oracle Queues getting stopped even though there are Ongoing transaction to be dequeued

Sarith Sreedharan, March 16, 2023 - 9:26 am UTC

Hi Chris,

Thanks for your quick response.

yes I was clear that no new transaction would be dequeued from the queue or enqueued to the queue.

Our only Concern was if the queue is stopped in between the dequeuing , message may be lost and was initially of the understanding that all pending records would get processed. Now I have got the clarity that when the queue is going to be stopped, system will only check if the ongoing transaction in progress get completed and queue would get stopped. Any further records pending on the queue would get dequeued only when the dequeue option is enabled back.

I hope I have summarized it correctly. if so we can mark this closed.

Chris Saxon
March 16, 2023 - 12:50 pm UTC

That is my understanding too

More to Explore

PL/SQL demos

Check out more PL/SQL tutorials on our LiveSQL tool.

PL/SQL docs

PL/SQL reference manual from the Oracle documentation library