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!
Vertx is an asynchronuous framework for high load applications, it uses Netty, new I/O and Event bus. Vertx was designed to be used for microservices and a number of vertx instances may run in a cluster for high availability.
x website (vertx.io) says, “Eclipse Vert. x is a toolkit for building reactive applications on the JVM.” It is event-driven, single-threaded, and non-blocking, which means you can handle many concurrent apps with a small number of threads. (If you know how the Node. js event loop works, Vert.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With