tag:blogger.com,1999:blog-6527688743456205256.post2503767017278352276..comments2023-12-18T09:38:33.215+11:00Comments on The Blas from Pas: Using Database Change Notification (DCN) with a Coherence CachePas Apicellahttp://www.blogger.com/profile/09389663166398991762noreply@blogger.comBlogger7125tag:blogger.com,1999:blog-6527688743456205256.post-29086953052748741132011-10-10T00:31:56.463+11:002011-10-10T00:31:56.463+11:00Hi Pas,
As for the problem that the database reg...Hi Pas,<br /><br /><br />As for the problem that the database registrations do not die if the listener has an abnormal exit (see amitstechblog's posting above)<br /><br />I've found the following measures can potentially help on the problem:<br /><br /><br />1.<br />The Java application should register a Shutdown hook to make sure the registrations are unregistered if the application is killed. Here's how you can potentially write such code:<br /><br /><br /><code><br />Runtime.getRuntime().addShutdownHook(new Thread() {<br /> public void run() { <br /> /* unregister here */<br /> }<br />});<br /></code><br />(Sorry for this lousy formatting. I really, really recent blogger's lack of formatting options for comments !!)<br /><br />Note that use of Shutdown hook does not catch all cases of abnormal exit but it is certainly better than nothing.<br /><br /><br />2. <br />On startup of the Java application it should query the <b>USER_CHANGE_NOTIFICATION_REGS</b> dictionary view to find orphaned registrations and then unregister those before proceeding.<br /><br />I think that together these two measures will solve the problem of orphaned registrations.Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-6527688743456205256.post-33185653311621388532011-09-09T21:04:44.343+10:002011-09-09T21:04:44.343+10:00Good Post. Something which I am also working on cu...Good Post. Something which I am also working on currently. I am currently facing an issue which is - If the application registers for database change notification and aborts before un-registering, the next attempt to register would fail with "ORA-29972: user does not have privilege to change/ create registration" and further attempts will fail with an error "ORA-29970: Specified registration id does not exist". <br /><br />A real time example of the above situation where the application aborts before un-registering could be power failures or network failures. <br /><br />I am not sure if you have faced this issue.Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-6527688743456205256.post-47318946906307975892010-04-13T09:43:33.812+10:002010-04-13T09:43:33.812+10:00I tested this with the 11.1.0.7 and 11.2.0.1 JDBC ...I tested this with the 11.1.0.7 and 11.2.0.1 JDBC driver and it worked ok for me. Output as follows:<br /><br />Started DCNDemo at Tue Apr 13 09:28:08 EST 2010<br />Showing tables which are part of the registration thus far<br />SCOTT.CUSTOM_TESTER is part of the registration.<br />Ended DCNDemo at Tue Apr 13 09:28:09 EST 2010<br /><br />I suggest you log a support ticket with oracle giveing your testcase showing it's not, my registration is the same code used in this blog entry above so nothing unique about it. The table was created as follows in a 11.1.0.7 RDBMS.<br /><br />create table CUSTOM_TESTER (col1 number);Pas Apicellahttps://www.blogger.com/profile/09389663166398991762noreply@blogger.comtag:blogger.com,1999:blog-6527688743456205256.post-55939592623546448622010-04-13T06:01:29.271+10:002010-04-13T06:01:29.271+10:00I believe I have found a bug in 11g. My call from ...I believe I have found a bug in 11g. My call from the change registration object to getTables:<br /><br /># String[] tableNames = dcr.getTables(); <br /># for(int i=0; i < tableNames.length; i++) <br /># { <br /># System.out.println(tableNames[i]+" successfully registered."); <br /># }<br /><br />Returns a truncated value. My table name is .CUSTOM_TESTER, where getTables() returns .CUSTOM. Truncating the table name following the underscore. A post on Oracle forums went unanswered and a search for similar issues showed posts that went unanswered as well. This is probably why my listener is not responding.eggmattershttps://www.blogger.com/profile/09773427157780914618noreply@blogger.comtag:blogger.com,1999:blog-6527688743456205256.post-62679223301097056572010-04-10T04:50:26.811+10:002010-04-10T04:50:26.811+10:00Excellent, that makse perfect sense. Thank you!Excellent, that makse perfect sense. Thank you!eggmattershttps://www.blogger.com/profile/09773427157780914618noreply@blogger.comtag:blogger.com,1999:blog-6527688743456205256.post-86658151482337386822010-04-07T18:40:15.086+10:002010-04-07T18:40:15.086+10:00I added the code to the main entry above, alot eas...I added the code to the main entry above, alot easier then adding to comments itself as it's difficult to format.<br /><br />DeptDCNRegister.java does the registration itself.Pas Apicellahttps://www.blogger.com/profile/09389663166398991762noreply@blogger.comtag:blogger.com,1999:blog-6527688743456205256.post-77140496098272912682010-04-07T02:30:18.891+10:002010-04-07T02:30:18.891+10:00This code is a little bit more lucid than the simi...This code is a little bit more lucid than the similair code provided by oracle. Trying to follow as my listener hangs and won't seem to acknowledge an event it is listening for. Curious though, what specifically is defined in your class object: DeptDCNRegister demo? I could imagine that it is the registered event?eggmattershttps://www.blogger.com/profile/09773427157780914618noreply@blogger.com