Skip to Main Content

Breadcrumb

Question and Answer

Connor McDonald

Thanks for the question, Jaroslav.

Asked: December 14, 2016 - 4:07 pm UTC

Last updated: December 15, 2016 - 3:27 am UTC

Version: 12

Viewed 1000+ times

You Asked

Hello Tom,

I have the folloging problem. My application accepts messages into queue and than dispatches (using subscriber agent) them to other system. Incomming messages can come in batches of 100 pieces in a short time and I want to dispatch them slowly - to have 10s delay between them.

I implemented the delay using package global variable which stores time of the last dequeue. When dequeuein the next message I read this variable, compute dequeue delay parameter, dequeneue message and store in variable new last dequeue time.

Problem is that dequeuing is not done within one session, but somehow in parallel and each thread has it's own copy of last dequeue variable.

I found couple of solutions - use pipes to exchange value between session, store this value in table updated by autonomous transaction, use context ...

And finaly my question - is there any way how to force the queue not to be dequeued in couple of parallel sessions, but just in one session ?

and Connor said...

I dont think there is a native facility to serialise the activity.

So your options would be:

a) write your own 'subscriber' code, ie, your own agent to listen on the queue and process them.

b) look at following the example in MOS note 225810.1 which handles a similar issue for the asynch plsql notification code, but manipulating the handler procedure.

For me, I'd probably go with (a), ie, it sounds like you want a good level of explicit control over the dequeue process.

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

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