服务器节点之间如何同步数据?
我有一个 Java EE 应用程序,它集群在两个 WebSphere V7 节点上。如果客户端更改了保存到节点 1 上数据库的数据,我想确保数据也立即在节点 2 上更新。
我考虑使用 EJB 计时器服务,该服务每隔几分钟检查一次数据库。但是,如果我想让更新按时执行,在节点 2 上没有任何延迟,并且不将间隔设置为一秒左右,该怎么办?好吧,我可以从节点 1 调用节点 2 上的 servlet 并以这种方式触发更新。但在这种情况下,我的应用程序必须知道所有节点的 http 地址。这不是我想要的。还有其他建议吗?
是否有在服务器节点之间同步数据更改的最佳实践?
I have a Java EE application which is clustered on two WebSphere V7 nodes. If a client changes data which is persisted to a database on node 1, I want to make sure that the data is updated immediately on node 2 as well.
I considered using an EJB timer service which does a check on the database every few minutes. But what can I do if I want to have the update to be performed on-time, without any delay on node 2 and not setting the interval to one second or so? Well I could call a servlet on node 2 from node 1 and trigger the update this way. But in this case my application has to know the http addresses of all nodes. This is not what I want. Any other suggestions?
Is there a best practice for synchronizing data changes between server nodes?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
由于您使用的是 WebSphere,我建议使用 DistributedMap 内置于 WAS 中。
Since you're using WebSphere I'd recommend using the DistributedMap that is built into WAS.
我建议使用 Jboss JGroups,它提供不同的同步方法。
http://www.jgroups.org/
I would recommend using Jboss JGroups which offers different synchronization methods.
http://www.jgroups.org/
假设您的两个 WebSphere 节点与同一个数据库通信,并且您没有添加任何形式的缓存,那么只要节点 2 在数据库上运行 SQL 查询,数据就可用。
我在你的问题中遗漏了什么吗?
Assuming that your two WebSphere nodes talk to the same database and you haven't added any form of caching then the data will be available as soon as Node 2 run a SQL query on the database.
Am I missing something in your question?