Hazelcast-确保进入事件由单个处理程序处理 [英] Hazelcast - Ensure entry event is processed by a single handler

查看:69
本文介绍了Hazelcast-确保进入事件由单个处理程序处理的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个带有多个节点的Hazelcast群集,每个节点都由守护程序"服务器进程的相同实例组成.这些守护程序是具有嵌入式Hazelcast缓存以及构成我平台核心的逻辑的Java应用程序.我需要将平台上的某些事件分发给整个群集中的侦听器,这些侦听器可以驻留在任何(或所有)连接的节点中.从我阅读的文档看来,如果在守护进程启动时将EntryEventListener附加到地图上,则无论何时在该地图中发生事件,都会在守护程序的每个运行实例中调用我的回调.

I have a Hazelcast cluster with multiple nodes, each consisting of identical instances of a "Daemon" server process. These daemons are Java applications with embedded Hazelcast caches as well as logic that forms the core of my platform. I need to distribute certain events on the platform to listeners across the cluster which can reside in any (or all) of the connected nodes. From my reading of the documentation it seems to me that if I attach an EntryEventListener to the maps on daemon startup then whenever the event happens in that map my callback will be called in every running instance of the daemon.

我想要的是针对事件在整个集群中一次(在任何单个节点上)调用一次回调.因此,如果我在集群中有10个节点,并且每个节点在加入时在地图上注册一个EntryEventListener,我希望事件发生时触发这些侦听器实例中的任何一个(在任何节点上),而不是全部他们...我不在乎哪个节点侦听器处理事件,只要它只是侦听器的单个实例,而不是每个注册的侦听器.我该怎么办?

What I would like is for the callback to be called once (on any single node) across the cluster for an event. So if I have 10 nodes in the cluster, and each node registers an EntryEventListener on a map when it joins I would like any single one of those listener instances (on any of the nodes) to be triggered when that event happens and not all of them... I don't care which node listener handles the event, as long as it is only a single instance of the listener and not every registered listener. How can I do this?

我看到了这个老问题,听起来像是同一个问题,但是我不确定,答案对我来说没有意义. 多节点群集上的hazelcast条目​​侦听器

I saw this old question which sounds like the same question, but I'm not certain and the answer doesn't make sense to me. hazelcast entry listener on a multinode cluster

在Hazelcast文档中是这样的:

In The Hazelcast documentation there is this:

还有另一个名为local的属性,该属性未显示在 以上例子.这也是一个布尔型属性,是可选的, 如果将其设置为true,则可以在本地听 成员.默认值为false.

There is also another attribute called local, which is not shown in the above examples. It is also a boolean attribute that is optional, and if you set it to true, you can listen to the items on the local member. Its default value is false.

本地"属性是否意味着将仅在作为密钥的主要所有者的节点上触发事件?

Does that "local" attribute mean that the event would be triggered only on the node that is the primary owner of the key?

谢谢, 特洛伊

推荐答案

是的,将local设置为true会使侦听器仅在成员是密钥的主要所有者时才触发事件.您可以使用本地侦听器来实现所需的目标

Yes, setting local to true will make the listener to fire events only if the member is the primary owner of the key. You can achieve what you want using local listeners

这篇关于Hazelcast-确保进入事件由单个处理程序处理的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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