Clustering and Shared Data in Vert.x

前端 未结 5 420
无人共我
无人共我 2021-02-01 07:09

I\'m developing in Vert.x (based on Netty and Hazelcast), and I\'m trying to share data between two server instances (eache of those instances in different machines, on the same

5条回答
  •  悲哀的现实
    2021-02-01 07:51

    Vert.x 2 does not support cluster-wide shared data. However, Vert.x 3 does expose an asynchronous API that wraps the underlying Hazelcast cluster manager.

    For Vert.x 2, though, you can use the Hazelcast instance directly in your worker verticles. Just use Hazelcast's static methods to get the Vert.x Hazelcast instance:

    HazelcastInstance hazelcast = Hazelcast.getAllHazelcastInstances().iterator().next();
    

    Note that you should only access the Hazelcast API directly in this way from within a worker verticle. The Hazelcast API is blocking, so it will block the event loop if used in a normal verticle.

提交回复
热议问题