This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
We have some core java functionality sitting on the application server. This needs to be called from an Oracle database table event (through Oracle triggers for example).
What is the best way to achieve this
1) Asynchronous call to the java web service on the app server from the Oracle table trigger
2) JMS messaging
3) Java app having a polling service to monitor the database table at regular intervals
4) Scheduler functionality like Quartz
5) any other practice for reverse direction functionality calling.
Joined: Nov 29, 2004
can some one provide tips on how to go about this.
I'd suggest to move the functionality to the database. You can create Java stored procedures in Oracle from 9i on, so you don't need to recode the functionality in PL/SQL.
Other possibility would be to use Database Change Notification, available in Oracle 10 and higher (Oracle 11 has some enhancements). You'll need compatible JDBC client though. This will call your Java procedure sitting on application server whenever a monitored table changes, and is usable with connection pools. However it is only suitable when the changes are infrequent, for heavily modified data this is not usable. This functionality is generally meant to allow caching data in the middle tier. When applicable, it is a good alternative to polling.
We successfully use these two techniques in our project. Messaging (Advanced Queuing in Oracle parlance) is certainly another option, though I have no experience with it.
I'd strongly discourage you from using triggers. Your database performace will suffer badly if you try it. (The Database Change Notification - DCN - mentioned earlier is asynchronous, therefore its impact on performance is not that strong.) Moreover, it's really tricky to get triggers right. The transaction that fired the trigger could be rolled back. If you call extenal code, you must make sure to rollback effects of these calls too. By contrast DCN informs you only about changes that were actually comited to the database.
subject: event propagation from database to app server java component