Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Oracle JDBC: Resuming a Database Change Notification Registration

Tags:

oracle

jdbc

I am looking at Oracle's DBCN API (Continuous Query Notification) and using it implement a stream of events indicating new and/or modified rows in the database.

What I am concerned about is this: If I configure and start a change listener and then my java client fails, the server side is still accumulating changes for delivery. However, when my java client resumes, my options appear to be limited:

  1. Start a new registration. I don't want to do this because it will just start a new registration (with the old one still running "clientless") and my new registration will not be sent the backlog of the prior registration.
  2. I can query the USER_CHANGE_NOTIFICATION_REGS table, find the prior registration and cancel it, but that still doesn't get me my backlog of undelivered notifications.

So how can I resume a session with an existing registration ? Alternatively, from where might I find and retrieve the backlogged notifications ?

Thanks.

//Nicholas

like image 210
Nicholas Avatar asked Nov 04 '22 03:11

Nicholas


1 Answers

You could implement a server side solution (PL/SQL) that will put all changes into a queue (Oracle Advanced Queue). Then your java client could connect against this queue and get the changes.

If your client fails, the changes will still get written into the queue on the server. And when you resume your client it will get all changes from the queue, resuming from the last you received.

like image 51
Matthias Avatar answered Nov 09 '22 14:11

Matthias