tomcat 6.0集群环境下如何实现缓存同步?

发布于 2024-09-15 01:47:38 字数 188 浏览 0 评论 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

我乃一代侩神 2024-09-22 01:47:38

可以使用,不需要启动线程之类的。
发送类实例需要 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

萝莉病 2024-09-22 01:47:38

您可以使用 Hazelcast 主题。这是一个非常轻量级的发布/订阅消息传递。每个节点都会监听该主题。当用户在任何节点上保存时,只需输入一些消息“REFRESH”。在接收时,每个节点都可以做任何你想做的事情。
这是执行此操作的代码:

String REFRESH = "REFRESH";
ITopic<String> topic = Hazelcast.getTopic("myTopic");
topic.addMessageListener(new MessageListener<String>() {
        public void onMessage(String msg) {
          if(REFRESH.equals(msg){   
           //do 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:

String REFRESH = "REFRESH";
ITopic<String> topic = Hazelcast.getTopic("myTopic");
topic.addMessageListener(new MessageListener<String>() {
        public void onMessage(String msg) {
          if(REFRESH.equals(msg){   
           //do refresh
          }
        }
    });

//when user saves sth.
topic.publish(REFRESH);

浮萍、无处依 2024-09-22 01:47:38

如果您使用手写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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文