Question :
I moved this question from stackoverflow to here as it was marked on hold as off-topic. On Oracle 10g2 DB I have set up multiple event triggered DMBS_SCHEDULER jobs and all of them are subscribed for the same event queue. The problem is when I call the function that enqueues the message in the advanced queue, therefore triggering the scheduler event all of the subscribed jobs are executed only once.
-
In the loop I am calling procedure that enqueues the messages in the
queue. (I did check the message count in the queue and it matches the
loop count); -
There are multiple jobs (or a single job – I did test both cases the
result is the same) that have event schedule and are subscribed to
the particular queue; -
After executing this loop, I do check the message count in the queue
and the instance count of the new jobs in sys.dba_scheduler_job_log.
Result – all the messages in the queue have been processed (meaning
it is empty) and only one instance per each job have been registered
in scheduler_job_log table; -
The thing is that if I add
DBMS_LOCK.sleep(1);
after at the end of the each iteration in the loop then all of the job instances are registered in the scheduler_log_table fine.
Why do all of the other queue messages processed from the queue without running the job? Are there any DBMS_SCHEDULER settings to be adjusted?
Answer :
This is a documented behavior so “it’s not a bug, it’s a feature”.
http://docs.oracle.com/cd/B19306_01/server.102/b14231/scheduse.htm#CHDIAJEB says:
events that occur while
the job is already running are ignored; the event gets consumed, but
does not trigger another run of the job.
And this documented behaviour can be bypassed by setting this attribute to the job before its enabled:
DBMS_SCHEDULER.set_attribute (‘my_job_name’, ‘parallel_instances’, TRUE);