Advanced
Checkpoint 6 — jobs & notifications
You should now be able to create queues, enqueue/dequeue messages with payloads and properties, consume asynchronously, and react to database change events.
The exercise — employee job queue
Server side: a job_t object payload, queue table + started queue (page 710).
create type job_t as object (job_id number, action varchar2(20), empno number);
The program — two modes in one binary:
jobs submit— reads job lines from stdin (RAISE 7566), buildsjob_tobjects, sets correlation"emp-" || empnoand priority, enqueues, commits.jobs work— anOCI_Dequeueconsumer that: - waits withDequeueSetWaitTime(-1), - on eachjob_t: performs the action (e.g.update employees set sal=sal*1.1), commits, prints theMsgGetID+MsgGetCorrelation.
Stretch:
- Replace polling with OCI_DequeueSubscribe + OCI_ENV_EVENTS callback.
- Add OCI_SubscriptionCreate on employees with OCI_CNT_ROWS and log which
ROWIDs your jobs changed.
- Two named consumers (OCI_Agent "CLERK"/"MANAGER") routed by MsgSetConsumers.
What it exercises
| Skill | Pages |
|---|---|
| Queue plumbing | 710 |
| Msg payloads + props | 715 |
| Dequeue options | 720 |
| Async agents | 725 |
| CQN subscriptions/events | 730 |
Part 7 done. Next: bulk loading (array binds, direct path) and admin.