简体   繁体   中英

Calling Java Application from Postgres Database trigger

I am trying to execute my java application once a record is inserted, deleted or update into a database table. For that sake, I am planning to write a Trigger which will be called while inserting. My question is that, will I be able to call a java application from this trigger?

While Python and Perl , among others, have a PL equivalent that can be written within an SQL function (albeit with sometimes considerable overhead), Java does not. Even if the Java app could be launched via command line or something after a trigger, the overhead in launching the JVM alone would be a performance disaster.

I would recommend looking into having Postgres emit notifications via notify . This would let you send a payload (although there are size limitations) that can be listened for by a client (that client could be your Java app, or an intermediate program that performed some additional ETL to get it ready for your app). This should allow for the data to be served up and processed in a performant way.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM