Dzmitry  Prakapenka
Dzmitry Prakapenka

Reputation: 734

Broadcast event with zookeeper

I want to broadcast event through zookeeper 3.4+.

Let say I have some producers that concurrently increments a counter and listeners watching to this increments.

I found I can update znode value from producer and listeners to these znode changes will be notified.

I can use apache curator shared count. I can assign listeners on this shared count commonly known path and if I will update (increment) shared count value, listeners will be notified.

Also I can use distributed atomic long and Node cache listener. Situation is same, I will create this atomic long on commonly known path. Listeners will listen to znode changes on this path. When I will update atomic long value, listeners of these node value will be notified.

1) Which zookeepers structure should I use for example above?

2) Can I be sure every update to shared count or distributed atomic long will be broadcasted and listeners are guaranteed to be notified?

3) Is it possible to any listener to miss count update event?

Upvotes: 1

Views: 733

Answers (1)

ShaharT
ShaharT

Reputation: 595

Path Children Cache should be the choice. It is more generic than the others, and it is better than the Node Cache as it gives the event's type (PathChildrenCacheEvent.Type) - is it a CONNECTION_RECONNECTED, or not.

Consult Curator's source code for extra info.

Upvotes: 2

Related Questions