title: pl/sql using trigger to gather queued messages in queue
body: <p>I am trying to work on altering an already existing queuing system... Which just gives me a headache...</p>
  
  <p>The logic behind the queues is all in Oracle DB as follows:</p>
  
  <ol>
  <li>Database #1 sends notifications, which are queued in Database #2 in a specific queue, let's name it Q1.</li>
  <li>There is a regular job, that executes a procedure in a package (DISPATCHER), which basically is a loop that dequeues all messages in Q1 until no messages are there. Its execution is scheduled every 5 minutes, yet with the amount of queue entries it runs longer than that.</li>
  <li>Dispatcher procedure distributes the messages to additional queues, from which Java processes the messages and things go further.</li>
  </ol>
  
  <p>There isn't much control over the dispatching JOB so I decided to look up ways of making the whole framework for dispatching jobs better. I must add it is an old implementation that worked for quite a while, but most don't find it easy to control or transparent.</p>
  
  <p>My point is if there are any secure ways of this dispatching process?</p>
  
  <ol>
  <li>I have created a trigger on the queue table that executes a single dequeue with all the processing of the message done in DISPATCHER and it works, but i don't know if it's best the idea.</li>
  <li>Looked up creating subscribers, but can't add any as it's a single-consumer queue. Considering i would have to update the framework, recreating the queue would delete all the messages that already are in the queue, which is something i'd like to omit...</li>
  <li>Tried a DBMS Scheduler job to execute the DISPATCHER for more control, but it just runs "when it has resources". I'm counting on a solution that works continuously and processes the messages as fast as it can.</li>
  <li>Maybe there is some more elaborate way to solve this problem, but i'm still a bit fresh and can't seem to grasp the whole advanced queuing mechanism...</li>
  </ol>
  
  <p>Thanks in advance.</p>