--
You received this message because you are subscribed to the Google Groups "vert.x" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vertx+un...@googlegroups.com.
Visit this group at https://groups.google.com/group/vertx.
To view this discussion on the web, visit https://groups.google.com/d/msgid/vertx/56b6eee7-4df7-4eab-8957-85718a5783c8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
import io.vertx.core.Vertx;
import io.vertx.core.VertxOptions;
import io.vertx.core.eventbus.Message;
import io.vertx.core.json.JsonArray;
import io.vertx.core.json.JsonObject;
import io.vertx.spi.cluster.hazelcast.HazelcastClusterManager;
public class Main {
public static void main(String[] args) {
Vertx.clusteredVertx(new VertxOptions().setClusterManager(new HazelcastClusterManager()), res -> {
if (res.succeeded()) {
Vertx vertx = res.result();
vertx.eventBus().consumer("example", Main::handleExample);
JsonObject request = new JsonObject()
.put("foo", "bar")
.put("array", new JsonArray()
.add(new JsonObject().put("foo", "bar"))
.add(new JsonObject().put("foo", "bar"))
);
vertx.setPeriodic(1000, id -> {
vertx.eventBus().send("example", request, response -> {
JsonObject jsonResponse = (JsonObject) response.result().body();
System.out.println(jsonResponse.getJsonArray("array").getList().get(0).getClass() + " received in the response");
});
});
} else {
// failed!
}
});
}
private static void handleExample(Message<JsonObject> message) {
JsonObject response = new JsonObject()
.put("baz", "qux")
.put("array", new JsonArray()
.add(new JsonObject().put("baz", "quz"))
.add(new JsonObject().put("baz", "quz"))
);
JsonArray requestArray = message.body().getJsonArray("array");
System.out.println(requestArray.getList().get(0).getClass() + " received in the request");
message.reply(response);
}
}
class io.vertx.core.json.JsonObject received in the request
class io.vertx.core.json.JsonObject received in the response
class io.vertx.core.json.JsonObject received in the request
class io.vertx.core.json.JsonObject received in the response
class io.vertx.core.json.JsonObject received in the request
class io.vertx.core.json.JsonObject received in the response
class java.util.LinkedHashMap received in the request
class java.util.LinkedHashMap received in the response
class io.vertx.core.json.JsonObject received in the request
class io.vertx.core.json.JsonObject received in the response
class java.util.LinkedHashMap received in the request
class java.util.LinkedHashMap received in the response
class io.vertx.core.json.JsonObject received in the request
class io.vertx.core.json.JsonObject received in the response
class java.util.LinkedHashMap received in the request
class java.util.LinkedHashMap received in the response
--
You received this message because you are subscribed to the Google Groups "vert.x" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vertx+un...@googlegroups.com.
Visit this group at https://groups.google.com/group/vertx.
To view this discussion on the web, visit https://groups.google.com/d/msgid/vertx/9c33cd7d-dc0c-423c-bbba-f477a1aaf6fe%40googlegroups.com.
--
You received this message because you are subscribed to the Google Groups "vert.x" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vertx+un...@googlegroups.com.
Visit this group at https://groups.google.com/group/vertx.
To view this discussion on the web, visit https://groups.google.com/d/msgid/vertx/43964bba-4e2f-4a4e-a91c-d8310ecfd7a7%40googlegroups.com.