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 lan).
My problem is that I don't know how to configure the vert.x servers to allow them to share their concurrent memory maps (the theory says that's possible).
I've read many documents off Vert.x and Hazelcast but I haven't had results yet. (I don't know how to force vert.x to load hazelcast xml configuration files).
Thanks in advance!
There are options for sharing data among vertx instances on different machines
Option 1.
You could use the Vert.x ClusterManager and it's maps:
ClusterManager clusterManager = ((VertxInternal)vertx).clusterManager();
Map map = clusterManager.getSyncMap("mapName"); // shared distributed map
That map is backed by a Hazelcast IMap and is distributed. This assumes you're running vertx with the -cluster
parameter and have configured clustering.
However note that this is internal API and is not generally recommended for production. If you are doing a one time experiment then it could be useful.
Option 2.
You can get access to Hazelcast once vertx is started in clustered mode:
Set<HazelcastInstance> instances = Hazelcast.getAllHazelcastInstances();
HazelcastInstance hz = instances.stream().findFirst().get();
Map map = hz.getMap("mapName"); // shared distributed map