监控mysql的变化 [英] monitoring mysql for changes

查看:189
本文介绍了监控mysql的变化的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个通过hibernate使用MySQL数据库的Java应用程序。数据库实际上用作持久层:数据库在程序的初始加载时被读取,然后记录被保存在内存中。



然而,我们正在添加额外的复杂性,其中另一个进程可能会更改数据库,并且这些更改反映在Java应用程序上会很好。然而,我并不特别喜欢每隔几秒钟就要抽出一些机制来查询数据库,尤其是数据库很少更新。



有没有办法让回调聆听数据库更改?触发器是否有帮助?

解决方案

或者更改这两个应用程序,以便Java应用程序确实是MySQL数据库的所有者并将其公开服务。通过完成您的建议,您可以在数据库级别连接两个应用程序。

如果您拥有一个数据所有者,您可以在服务界面后隐藏模式更改等。您还可以通过发布/订阅机制来提醒感兴趣的各方关于数据库更改。如果这些事情对您很重要,我会重新考虑让其他应用程序直接访问MySQL。


I have a Java app using a MySQL database through hibernate. The database is really used as persistence layer: The database is read at the initial load of the program, and the records are then maintained in memory.

However, we are adding extra complexity, where another process may change the database as well, and it would be nice for the changes to reflect on the Java app. Yet, I don't particularly like pulling mechanisms to query the database every few seconds, especially that the database is rarely updated.

Is there a way to have a callback to listen to database changes? Would triggers help?

解决方案

Or change both applications so the Java app is truly the owner of the MySQL database and exposes it as a service. You're coupling the two apps at the database level by doing what you're proposing.

If you have one owner of the data you can hide schema changes and such behind the service interface. You can also make it possible to have a publish/subscribe mechanism to alert interested parties about database changes. If those things are important to you, I'd reconsider letting another application access MySQL directly.

这篇关于监控mysql的变化的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆