List of usage examples for io.vertx.core.eventbus EventBus send
@Fluent EventBus send(String address, @Nullable Object message, DeliveryOptions options);
From source file:docoverride.eventbus.Examples.java
License:Open Source License
public void example10(EventBus eventBus, MessageCodec myCodec) { eventBus.registerCodec(myCodec);//from w w w . ja va 2 s . co m DeliveryOptions options = new DeliveryOptions().setCodecName(myCodec.name()); eventBus.send("orders", new MyPOJO(), options); }
From source file:docoverride.eventbus.Examples.java
License:Open Source License
public void headers(EventBus eventBus) { DeliveryOptions options = new DeliveryOptions(); options.addHeader("some-header", "some-value"); eventBus.send("news.uk.sport", "Yay! Someone kicked a ball", options); }
From source file:examples.EventBusExamples.java
License:Open Source License
public void example9(EventBus eventBus) { eventBus.send("news.uk.sport", "Yay! Someone kicked a ball across a patch of grass", ar -> { if (ar.succeeded()) { System.out.println("Received reply: " + ar.result().body()); }// w w w . j a va2s.c om }); }
From source file:org.entcore.common.appregistry.ApplicationUtils.java
License:Open Source License
private static void applicationInfos(EventBus eb, String action, String application, JsonArray users, JsonArray groups, final Handler<JsonArray> handler) { JsonObject json = new JsonObject(); json.put("action", action).put("application", application); if (users != null) { json.put("users", users); }/* w w w. ja va 2 s . c o m*/ if (groups != null) { json.put("groups", groups); } eb.send(APP_REGISTRY_ADDRESS, json, new Handler<AsyncResult<Message<JsonArray>>>() { @Override public void handle(AsyncResult<Message<JsonArray>> event) { if (event.succeeded()) { handler.handle(event.result().body()); } else { handler.handle(null); } } }); }
From source file:org.entcore.common.appregistry.ApplicationUtils.java
License:Open Source License
public static void sendModifiedUserGroup(EventBus eb, JsonArray a, Handler<AsyncResult<Message<JsonObject>>> res) { eb.send(APP_REGISTRY_PUBLISH_ADDRESS, new JsonObject().put("type", USER_GROUP_UPDATED).put("users", a), res);/*from w w w . ja va 2 s .c o m*/ }
From source file:org.entcore.common.appregistry.ApplicationUtils.java
License:Open Source License
public static void setDefaultClassRoles(EventBus eb, String classId, Handler<AsyncResult<Message<JsonObject>>> handler) { JsonObject json = new JsonObject(); json.put("action", "setDefaultClassRoles").put("classId", classId); eb.send(APP_REGISTRY_BUS_ADDRESS, json, handler); }
From source file:org.entcore.common.notification.NotificationUtils.java
License:Open Source License
public static void getUsersPreferences(EventBus eb, JsonArray userIds, String fields, final Handler<JsonArray> handler) { eb.send(USERBOOK_ADDRESS, new JsonObject().put("action", "get.userlist").put("application", "timeline") .put("additionalMatch", ", u-[:IN]->(g:Group)-[:AUTHORIZED]->(r:Role)-[:AUTHORIZE]->(act:WorkflowAction) ") .put("additionalWhere", "AND act.name = \"org.entcore.timeline.controllers.TimelineController|mixinConfig\" ") .put("additionalCollectFields", ", " + fields).put("userIds", userIds), handlerToAsyncHandler(new Handler<Message<JsonObject>>() { public void handle(Message<JsonObject> event) { if (!"error".equals(event.body().getString("status"))) { handler.handle(event.body().getJsonArray("results")); } else { handler.handle(null); }// w w w .ja va 2 s . c o m } })); }
From source file:org.entcore.common.storage.impl.GridfsStorage.java
License:Open Source License
private static void gridfsReadChunkFile(final String id, final EventBus eb, final String gridfsAddress, final WriteStream writeStream, final Handler<Chunk> handler) { JsonObject find = new JsonObject(); find.put("action", "countChunks"); find.put("files_id", id); byte[] header = null; try {/*from w w w.jav a 2 s .c o m*/ header = find.toString().getBytes("UTF-8"); } catch (UnsupportedEncodingException e) { log.error(e.getMessage(), e); handler.handle(null); } if (header != null) { Buffer buf = Buffer.buffer(header); buf.appendInt(header.length); eb.send(gridfsAddress, buf, new Handler<AsyncResult<Message<Object>>>() { @Override public void handle(AsyncResult<Message<Object>> res) { if (res.succeeded() && res.result().body() instanceof Long) { Long number = (Long) res.result().body(); if (number == null || number == 0l) { handler.handle(null); } else { final Handler[] handlers = new Handler[number.intValue()]; handlers[handlers.length - 1] = new Handler<Chunk>() { @Override public void handle(Chunk chunk) { handler.handle(chunk); handler.handle(new Chunk(-1, null)); } }; for (int i = number.intValue() - 2; i >= 0; i--) { final int j = i; handlers[i] = new Handler<Chunk>() { @Override public void handle(final Chunk chunk) { if (writeStream != null && writeStream.writeQueueFull()) { writeStream.drainHandler(new Handler<Void>() { @Override public void handle(Void event) { log.debug("in drain handler"); writeStream.drainHandler(null); handler.handle(chunk); getChunk(id, j + 1, eb, gridfsAddress, new Handler<Chunk>() { @Override public void handle(Chunk res) { handlers[j + 1].handle(res); } }); } }); } else { handler.handle(chunk); getChunk(id, j + 1, eb, gridfsAddress, new Handler<Chunk>() { @Override public void handle(Chunk res) { handlers[j + 1].handle(res); } }); } } }; } getChunk(id, 0, eb, gridfsAddress, handlers[0]); } } else { handler.handle(null); } } }); } }
From source file:org.entcore.common.storage.impl.GridfsStorage.java
License:Open Source License
public static void getChunk(String id, final int j, EventBus eb, String gridfsAddress, final Handler<Chunk> handler) { JsonObject find = new JsonObject(); find.put("action", "getChunk"); find.put("files_id", id); find.put("n", j); byte[] header = null; try {//from www . j a va 2 s. c o m header = find.toString().getBytes("UTF-8"); } catch (UnsupportedEncodingException e) { handler.handle(null); } Buffer buf = Buffer.buffer(header); buf.appendInt(header.length); eb.send(gridfsAddress, buf, new Handler<AsyncResult<Message<Buffer>>>() { @Override public void handle(AsyncResult<Message<Buffer>> res) { if (res.succeeded()) { handler.handle(new Chunk(j, res.result().body())); } else { handler.handle(null); } } }); }
From source file:org.entcore.common.user.UserUtils.java
License:Open Source License
private static void findUsers(final EventBus eb, String userId, final JsonObject query, final Handler<JsonArray> handler) { if (userId != null && !userId.trim().isEmpty()) { query.put("userId", userId); eb.send(COMMUNICATION_USERS, query, new Handler<AsyncResult<Message<JsonArray>>>() { @Override//from ww w.j av a 2 s . c o m public void handle(AsyncResult<Message<JsonArray>> res) { if (res.succeeded()) { handler.handle(res.result().body()); } else { handler.handle(new fr.wseduc.webutils.collections.JsonArray()); } } }); } else { handler.handle(new fr.wseduc.webutils.collections.JsonArray()); } }