Martin Cowie
Martin Cowie

Reputation: 2601

Using Hazelcast as a service directory?

I am exploring the notion of using Hazelcast (or any another caching framework) to advertise services within a cluster. Ideally when a cluster member departs then its services (or objects advertising them) should be removed from the cache.

Is this at all possible?

Upvotes: 3

Views: 584

Answers (1)

pveentjer
pveentjer

Reputation: 11307

It is possible for sure.

The question is: which solution do you like.

If the services can be stored in a map, you could create a map with a ttl of e.g. a few minutes and each member needs to refresh its service to prevent the services from expiring.

An alternative solution is to listen to member changes using the membershiplistener and once a member leaves, the services that belong to that member need to be removed from the map.

If you don't like none of this, you could create your own SPI based implementation. The SPI is the lower level infrastructure used by hazelcast to create its distributed datastructures. A lot more work, but also a lot of flexibility.

So there are many solutions.

Upvotes: 3

Related Questions