List of usage examples for io.vertx.core.eventbus Message headers
MultiMap headers();
From source file:com.glt.rest.client.RestServiceVertxProxyHandler.java
License:Apache License
public void handle(Message<JsonObject> msg) { JsonObject json = msg.body();// w ww. j ava 2 s. c om String action = msg.headers().get("action"); if (action == null) { throw new IllegalStateException("action not specified"); } accessed(); switch (action) { case "get": { service.get((io.vertx.core.json.JsonObject) json.getValue("command"), createHandler(msg)); break; } case "post": { service.post((io.vertx.core.json.JsonObject) json.getValue("command"), createHandler(msg)); break; } case "put": { service.put((io.vertx.core.json.JsonObject) json.getValue("command"), createHandler(msg)); break; } case "delete": { service.delete((io.vertx.core.json.JsonObject) json.getValue("command"), createHandler(msg)); break; } case "getJson": { service.getJson((io.vertx.core.json.JsonObject) json.getValue("command"), createHandler(msg)); break; } case "postJson": { service.postJson((io.vertx.core.json.JsonObject) json.getValue("command"), createHandler(msg)); break; } case "putJson": { service.putJson((io.vertx.core.json.JsonObject) json.getValue("command"), createHandler(msg)); break; } case "deleteJson": { service.deleteJson((io.vertx.core.json.JsonObject) json.getValue("command"), createHandler(msg)); break; } case "request": { service.request((io.vertx.core.json.JsonObject) json.getValue("command"), createHandler(msg)); break; } default: { throw new IllegalStateException("Invalid action: " + action); } } }
From source file:com.jedlab.vertee.DatabaseServiceVertxProxyHandler.java
License:Apache License
public void handle(Message<JsonObject> msg) { try {//from www . j a v a 2 s . c om JsonObject json = msg.body(); String action = msg.headers().get("action"); if (action == null) { throw new IllegalStateException("action not specified"); } accessed(); switch (action) { case "persist": { service.persist((io.vertx.core.json.JsonObject) json.getValue("document"), createHandler(msg)); break; } default: { throw new IllegalStateException("Invalid action: " + action); } } } catch (Throwable t) { msg.reply(new ServiceException(500, t.getMessage())); throw t; } }
From source file:com.panjiesw.std.service.user.UserServiceVertxProxyHandler.java
License:Apache License
public void handle(Message<JsonObject> msg) { JsonObject json = msg.body();//from w w w.j a v a 2s. com String action = msg.headers().get("action"); if (action == null) { throw new IllegalStateException("action not specified"); } accessed(); switch (action) { case "save": { service.save((io.vertx.core.json.JsonObject) json.getValue("payload"), createHandler(msg)); break; } case "query": { service.query((java.lang.String) json.getValue("sql"), createListHandler(msg)); break; } case "queryOne": { service.queryOne((java.lang.String) json.getValue("sql"), createHandler(msg)); break; } case "one": { service.one((java.lang.Long) json.getValue("id"), createHandler(msg)); break; } case "findByUsername": { service.findByUsername((java.lang.String) json.getValue("username"), createHandler(msg)); break; } case "findByEmail": { service.findByEmail((java.lang.String) json.getValue("email"), createHandler(msg)); break; } case "start": { service.start(createHandler(msg)); break; } case "stop": { service.stop(createHandler(msg)); close(); break; } default: { throw new IllegalStateException("Invalid action: " + action); } } }
From source file:com.pluralsight.dockerproductionaws.portfolio.PortfolioServiceVertxProxyHandler.java
License:Apache License
public void handle(Message<JsonObject> msg) { try {/* ww w .ja v a 2 s . c om*/ JsonObject json = msg.body(); String action = msg.headers().get("action"); if (action == null) { throw new IllegalStateException("action not specified"); } accessed(); switch (action) { case "getPortfolio": { service.getPortfolio(res -> { if (res.failed()) { if (res.cause() instanceof ServiceException) { msg.reply(res.cause()); } else { msg.reply(new ServiceException(-1, res.cause().getMessage())); } } else { msg.reply(res.result() == null ? null : res.result().toJson()); } }); break; } case "buy": { service.buy(json.getValue("amount") == null ? null : (json.getLong("amount").intValue()), (io.vertx.core.json.JsonObject) json.getValue("quote"), res -> { if (res.failed()) { if (res.cause() instanceof ServiceException) { msg.reply(res.cause()); } else { msg.reply(new ServiceException(-1, res.cause().getMessage())); } } else { msg.reply(res.result() == null ? null : res.result().toJson()); } }); break; } case "sell": { service.sell(json.getValue("amount") == null ? null : (json.getLong("amount").intValue()), (io.vertx.core.json.JsonObject) json.getValue("quote"), res -> { if (res.failed()) { if (res.cause() instanceof ServiceException) { msg.reply(res.cause()); } else { msg.reply(new ServiceException(-1, res.cause().getMessage())); } } else { msg.reply(res.result() == null ? null : res.result().toJson()); } }); break; } case "evaluate": { service.evaluate(createHandler(msg)); break; } default: { throw new IllegalStateException("Invalid action: " + action); } } } catch (Throwable t) { msg.reply(new ServiceException(500, t.getMessage())); throw t; } }
From source file:com.reachauto.account.AccountServiceVertxProxyHandler.java
License:Apache License
public void handle(Message<JsonObject> msg) { try {/*from w w w. ja v a 2 s. c o m*/ JsonObject json = msg.body(); String action = msg.headers().get("action"); if (action == null) { throw new IllegalStateException("action not specified"); } accessed(); switch (action) { case "addAccount": { service.addAccount( json.getJsonObject("account") == null ? null : new com.reachauto.account.Account(json.getJsonObject("account")), createHandler(msg)); break; } case "deleteAccount": { service.deleteAccount(json.getValue("id") == null ? null : (json.getLong("id").intValue()), createHandler(msg)); break; } case "updateAccount": { service.updateAccount(json.getJsonObject("account") == null ? null : new com.reachauto.account.Account(json.getJsonObject("account")), res -> { if (res.failed()) { if (res.cause() instanceof ServiceException) { msg.reply(res.cause()); } else { msg.reply(new ServiceException(-1, res.cause().getMessage())); } } else { msg.reply(res.result() == null ? null : res.result().toJson()); } }); break; } case "retrieveAccount": { service.retrieveAccount(json.getValue("id") == null ? null : (json.getLong("id").intValue()), res -> { if (res.failed()) { if (res.cause() instanceof ServiceException) { msg.reply(res.cause()); } else { msg.reply(new ServiceException(-1, res.cause().getMessage())); } } else { msg.reply(res.result() == null ? null : res.result().toJson()); } }); break; } default: { throw new IllegalStateException("Invalid action: " + action); } } } catch (Throwable t) { msg.reply(new ServiceException(500, t.getMessage())); throw t; } }
From source file:com.reachauto.device.DeviceServiceVertxProxyHandler.java
License:Apache License
public void handle(Message<JsonObject> msg) { try {/* w w w. j ava 2 s.c om*/ JsonObject json = msg.body(); String action = msg.headers().get("action"); if (action == null) { throw new IllegalStateException("action not specified"); } accessed(); switch (action) { case "addDevice": { service.addDevice( json.getJsonObject("device") == null ? null : new com.reachauto.device.Device(json.getJsonObject("device")), createHandler(msg)); break; } case "deleteDevice": { service.deleteDevice((java.lang.String) json.getValue("id"), createHandler(msg)); break; } case "updateDevice": { service.updateDevice(json.getJsonObject("device") == null ? null : new com.reachauto.device.Device(json.getJsonObject("device")), res -> { if (res.failed()) { if (res.cause() instanceof ServiceException) { msg.reply(res.cause()); } else { msg.reply(new ServiceException(-1, res.cause().getMessage())); } } else { msg.reply(res.result() == null ? null : res.result().toJson()); } }); break; } case "retrieveDevice": { service.retrieveDevice((java.lang.String) json.getValue("id"), res -> { if (res.failed()) { if (res.cause() instanceof ServiceException) { msg.reply(res.cause()); } else { msg.reply(new ServiceException(-1, res.cause().getMessage())); } } else { msg.reply(res.result() == null ? null : res.result().toJson()); } }); break; } default: { throw new IllegalStateException("Invalid action: " + action); } } } catch (Throwable t) { msg.reply(new ServiceException(500, t.getMessage())); throw t; } }
From source file:com.reachauto.product.ProductServiceVertxProxyHandler.java
License:Apache License
public void handle(Message<JsonObject> msg) { try {//from w ww.j a v a2 s . c om JsonObject json = msg.body(); String action = msg.headers().get("action"); if (action == null) { throw new IllegalStateException("action not specified"); } accessed(); switch (action) { case "addProduct": { service.addProduct( json.getJsonObject("product") == null ? null : new com.reachauto.product.Product(json.getJsonObject("product")), createHandler(msg)); break; } case "deleteProduct": { service.deleteProduct(json.getValue("id") == null ? null : (json.getLong("id").intValue()), createHandler(msg)); break; } case "updateProduct": { service.updateProduct(json.getJsonObject("product") == null ? null : new com.reachauto.product.Product(json.getJsonObject("product")), res -> { if (res.failed()) { if (res.cause() instanceof ServiceException) { msg.reply(res.cause()); } else { msg.reply(new ServiceException(-1, res.cause().getMessage())); } } else { msg.reply(res.result() == null ? null : res.result().toJson()); } }); break; } case "retrieveProduct": { service.retrieveProduct(json.getValue("id") == null ? null : (json.getLong("id").intValue()), res -> { if (res.failed()) { if (res.cause() instanceof ServiceException) { msg.reply(res.cause()); } else { msg.reply(new ServiceException(-1, res.cause().getMessage())); } } else { msg.reply(res.result() == null ? null : res.result().toJson()); } }); break; } default: { throw new IllegalStateException("Invalid action: " + action); } } } catch (Throwable t) { msg.reply(new ServiceException(500, t.getMessage())); throw t; } }
From source file:com.test.db.DbServiceVertxProxyHandler.java
License:Apache License
public void handle(Message<JsonObject> msg) { try {//from w ww. j a v a2s. co m JsonObject json = msg.body(); String action = msg.headers().get("action"); if (action == null) { throw new IllegalStateException("action not specified"); } accessed(); switch (action) { case "storedProc": { service.storedProc((java.lang.String) json.getValue("procName"), (io.vertx.core.json.JsonObject) json.getValue("databaseConfig"), createHandler(msg)); break; } case "createStm": { service.createStm((java.lang.String) json.getValue("query"), (io.vertx.core.json.JsonObject) json.getValue("databaseConfig"), createHandler(msg)); break; } case "update": { service.update((java.lang.String) json.getValue("query"), (io.vertx.core.json.JsonObject) json.getValue("databaseConfig"), createHandler(msg)); break; } case "delete": { service.delete((java.lang.String) json.getValue("query"), (io.vertx.core.json.JsonObject) json.getValue("databaseConfig"), createHandler(msg)); break; } case "read": { service.read((java.lang.String) json.getValue("query"), (io.vertx.core.json.JsonObject) json.getValue("databaseConfig"), createHandler(msg)); break; } case "nonSharedRead": { service.nonSharedRead((java.lang.String) json.getValue("query"), (io.vertx.core.json.JsonObject) json.getValue("databaseConfig"), createHandler(msg)); break; } default: { throw new IllegalStateException("Invalid action: " + action); } } } catch (Throwable t) { msg.fail(-1, t.getMessage()); throw t; } }
From source file:com.test.mailer.MailerServiceVertxProxyHandler.java
License:Apache License
public void handle(Message<JsonObject> msg) { try {/*www . ja v a2 s . co m*/ JsonObject json = msg.body(); String action = msg.headers().get("action"); if (action == null) { throw new IllegalStateException("action not specified"); } accessed(); switch (action) { case "sendAttachment": { service.sendAttachment((java.lang.String) json.getValue("To"), json.getJsonObject("attachment") == null ? null : new io.vertx.ext.mail.MailAttachment(json.getJsonObject("attachment")), (java.lang.String) json.getValue("Title"), createHandler(msg)); break; } default: { throw new IllegalStateException("Invalid action: " + action); } } } catch (Throwable t) { msg.reply(new ServiceException(500, t.getMessage())); throw t; } }
From source file:de.notizwerk.Producer.java
License:Open Source License
@Override public void start() throws Exception { setUpFileSystem(v -> {//from w ww .ja v a2s . c o m vertx.setPeriodic(REPORT_DELAY_IN_MSEC, this::report); vertx.setTimer(SEND_DELAY_IN_MSEC, this::generateAndSend); vertx.eventBus().consumer("producer.control", (Message<JsonObject> msg) -> { String action = msg.headers().get("action"); switch (action) { case "startSending": this.sendingActive = true; break; case "stopSending": this.sendingActive = false; break; case "clearStats": this.sentMessages = 0; this.generatedMessages = 0; this.undeliveredMessages = 0; this.generatedMessagesInTick = 0; break; case "throttle": this.msgPerSec = msg.body().getLong("throttle", -1l); break; } }); }); }