开发者

Any way a db change can trigger a method call in Rails?

开发者 https://www.devze.com 2023-01-17 00:23 出处:网络
Is there any way a database change (say an insert statement) can trigger a call to a ruby开发者_StackOverflow method in my app? I know about observers but this is sort of a complicated situation, beca

Is there any way a database change (say an insert statement) can trigger a call to a ruby开发者_StackOverflow method in my app? I know about observers but this is sort of a complicated situation, because the database is updated by a Java application.

Note, both the Rails and the Java app connect to the same database.


  1. Polling DB by Rails app - in regular time intervals.
  2. Introduce table trigger which runs pl/ruby, pl/* or whatever to ping command-line, REST or web service of Rails app.
  3. Java app 'pings' Rails app (via REST, SOAP etc) after DB change.

In case 2&3 ping event can contain some more information - e.g. row id.

0

精彩评论

暂无评论...
验证码 换一张
取 消