Discussions
Categories
- 197.1K All Categories
- 2.5K Data
- 546 Big Data Appliance
- 1.9K Data Science
- 450.7K Databases
- 221.9K General Database Discussions
- 3.8K Java and JavaScript in the Database
- 31 Multilingual Engine
- 552 MySQL Community Space
- 479 NoSQL Database
- 7.9K Oracle Database Express Edition (XE)
- 3.1K ORDS, SODA & JSON in the Database
- 555 SQLcl
- 4K SQL Developer Data Modeler
- 187.2K SQL & PL/SQL
- 21.4K SQL Developer
- 296.3K Development
- 17 Developer Projects
- 139 Programming Languages
- 293K Development Tools
- 110 DevOps
- 3.1K QA/Testing
- 646.1K Java
- 28 Java Learning Subscription
- 37K Database Connectivity
- 158 Java Community Process
- 105 Java 25
- 22.1K Java APIs
- 138.2K Java Development Tools
- 165.3K Java EE (Java Enterprise Edition)
- 19 Java Essentials
- 162 Java 8 Questions
- 86K Java Programming
- 81 Java Puzzle Ball
- 65.1K New To Java
- 1.7K Training / Learning / Certification
- 13.8K Java HotSpot Virtual Machine
- 94.3K Java SE
- 13.8K Java Security
- 205 Java User Groups
- 24 JavaScript - Nashorn
- Programs
- 468 LiveLabs
- 39 Workshops
- 10.2K Software
- 6.7K Berkeley DB Family
- 3.5K JHeadstart
- 5.7K Other Languages
- 2.3K Chinese
- 175 Deutsche Oracle Community
- 1.1K Español
- 1.9K Japanese
- 233 Portuguese
Event-Based Jobs

Hi All,
Creating the event ques.
CREATE OR REPLACE TYPE t_event_queue_payload AS OBJECT (
event_name VARCHAR2(30)
);
/
BEGIN
-- Create a queue table to hold the event queue.
DBMS_AQADM.create_queue_table(
queue_table => 'event_queue_tab',
queue_payload_type => 't_event_queue_payload',
multiple_consumers => TRUE,
comment => 'Queue Table For Event Messages');
-- Create the event queue.
DBMS_AQADM.create_queue (
queue_name => 'event_queue',
queue_table => 'event_queue_tab');
-- Start the event queue.
DBMS_AQADM.start_queue (queue_name => 'event_queue');
END;
/
BEGIN
DBMS_SCHEDULER.create_job (
job_name => 'event_based_job',
job_type => 'PLSQL_BLOCK',
job_action => 'BEGIN
INSERT INTO scheduler_test (id, created_date)
VALUES (scheduler_test_seq.NEXTVAL, SYSDATE);
COMMIT;
END;',
start_date => SYSTIMESTAMP,
event_condition => 'tab.user_data.event_name = ''give_me_a_prod''',
queue_spec => 'event_queue',
enabled => TRUE);
END;
/
DECLARE
l_enqueue_options DBMS_AQ.enqueue_options_t;
l_message_properties DBMS_AQ.message_properties_t;
l_message_handle RAW(16);
l_queue_msg t_event_queue_payload;
BEGIN
l_queue_msg := t_event_queue_payload('give_me_a_prod');
DBMS_AQ.enqueue(queue_name => 'event_queue',
enqueue_options => l_enqueue_options,
message_properties => l_message_properties,
payload => l_queue_msg,
msgid => l_message_handle);
COMMIT;
END;
/
after ran the above plsql block, scheduler got triggered and insert the data into table. this is working fine.
my requirement :
1. i dropped the job ->>( job_name => 'event_based_job').after that, i ran the above plsql block 2 times.
2 entries are there event_queue_tab table.
2. after that ,i will create the DBMS_SCHEDULER.create_job
3.once created the schedular, after 1 min later this job need to be trigger ,why because 2 entries are the in event_queue_tab table and it not happing.
if there any solution for this?
Thanks
Answers
-
The queue triggered event job only when the enqueue occurs. Moreover, if a new enqueue occurs during the job execution, the scheduler will skip that event.
Simplest way is to start a single non-event job with a continuous dequeuing. Or enable multiple event job instances and dequeue all messages on startup. The third option is to register the pl/sql callback, but you still need to read messages on startup. Pl/sql callback is starting up to 20 processes on simultaneous enqueue.
-
i enable this one as well, still ,it is not working.
DBMS_SCHEDULER.SET_ATTRIBUTE('<<jobname>>','parallel_instances',TRUE);
As per your comment " enable multiple event job instances and dequeue all messages on startup. "
do you have sample,please share it?
-
Parallel_instances is needed to solve this problem:
Note:
The Scheduler runs the event-based job for each occurrence of an event that matches
event_condition
. However, by default, events that occur while the job is already running are ignored; the event gets consumed, but does not trigger another run of the job. Beginning in Oracle Database 11g Release 1 (11.1), you can change this default behavior by setting the job attributePARALLEL_INSTANCES
toTRUE
. In this case, an instance of the job is started for every instance of the event, and all job instances are lightweight jobs. See theSET_ATTRIBUTE
procedure in Oracle Database PL/SQL Packages and Types Reference for details.How to dequeue messages from queue, you can find in the documentation Advanced Queuing User's Guide (pl/sql). See also Administrators Guide about event based jobs.
-
i tried with parallel instance,it is not working.still event are the in que table.