tomcat 6.0集群环境下如何实现缓存同步?
我目前正在迁移一个在集群中运行的 Web 应用程序。该应用程序使用缓存。如果用户保存某些内容,某些缓存会被重新加载。我想将此情况通知集群的其他节点,以便所有节点刷新其缓存。
看来tomcat服务器内置了群组消息传递功能。(部落) 我想知道是否可以使用此消息传递来完成我的任务以及如何让事件侦听器运行一整天。
谨致问候 迈克尔
I'm currently working on a migration a web application to run in a cluster. This application uses caches. Some of this caches are reloaded in case the user saves something. I'ld like to inform the other nodes of the cluster about this, so that all nodes refresh their caches.
It seems that the tomcat server has a group messaging build in. (Tribes)
I'm wondering if I can use this messaging for my task and how to have the event listener run the whole day then.
with kind regards
Michael
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
可以使用,不需要启动线程之类的。
发送类实例需要 tomcat lib 目录中的消息类 jar。
干杯
米凯
It is possible to use it and there is no need to start a thread or the like.
Sending class instances around requires a jar of the message class in tomcat lib directory.
cheers
Michae
您可以使用 Hazelcast 主题。这是一个非常轻量级的发布/订阅消息传递。每个节点都会监听该主题。当用户在任何节点上保存时,只需输入一些消息“REFRESH”。在接收时,每个节点都可以做任何你想做的事情。
这是执行此操作的代码:
//当用户保存某事时。
主题.发布(刷新);
You can use Hazelcast Topic. It is a very lightweight pub/sub messaging. Each node will listen to the topic. When user saves smth on any node just put some message "REFRESH". On receive each node can do whatever you want.
Here is the code to do this:
//when user saves sth.
topic.publish(REFRESH);
如果您使用手写CACHE,那么您可以使用消息广播/接收来同步集群中所有节点的缓存B/W,您可以使用
JGROUP
来实现。例如:节点更新缓存,它只是将消息广播到其他节点以重新填充(
刷新
)其缓存If you are using handwritten CACHE, Than you can synchronize cache B/W all nodes of cluster using message broadcasting/receiving , You can use
JGROUP
for that.for ex: node A update cache that it just broad cast message to other node to refill(
refresh
) their cache