Search in sources :

Example 11 with Address

use of io.vertx.up.annotations.Address in project vertx-zero by silentbalanceyh.

the class DbWorker method sayDb.

@Address("ZERO://QUEUE/NATIVE/GET")
public void sayDb(final Message<Envelop> message) {
    final String type = Ux.getString(message);
    this.client.queryWithParams("SELECT * FROM SYS_TABULAR WHERE S_TYPE=?", new JsonArray().add(type), handler -> {
        // Success or Failure
        if (handler.succeeded()) {
            final ResultSet res = handler.result();
            // Build result json array
            for (final JsonArray item : res.getResults()) {
                System.out.println(item);
            }
            message.reply(Envelop.success(res.getResults()));
        } else {
            // Replied with error, now only print stack
            handler.cause().printStackTrace();
            message.reply(Envelop.ok());
        }
    });
}
Also used : JsonArray(io.vertx.core.json.JsonArray) ResultSet(io.vertx.ext.sql.ResultSet) Address(io.vertx.up.annotations.Address)

Example 12 with Address

use of io.vertx.up.annotations.Address in project vertx-zero by silentbalanceyh.

the class SearchWorker method search.

@Address("ZERO://QUEUE/SEARCH")
public Future<JsonObject> search(final Envelop envelop) {
    final JsonObject data = Ux.getJson(envelop);
    System.out.println(data);
    return this.searchStub.search(Ux.getInquiry(data, "tabular"));
}
Also used : JsonObject(io.vertx.core.json.JsonObject) Address(io.vertx.up.annotations.Address)

Example 13 with Address

use of io.vertx.up.annotations.Address in project vertx-zero by silentbalanceyh.

the class SimpleWorker method sayHello.

@Address("EXP3://QUEUE/VALIDATE")
public void sayHello(final Message<Envelop> message) {
    final JsonObject data = Ux.getJson(message);
    Params.start(this.getClass()).monitor(data).end();
    message.reply(Envelop.success("Response Successfully"));
}
Also used : JsonObject(io.vertx.core.json.JsonObject) Address(io.vertx.up.annotations.Address)

Example 14 with Address

use of io.vertx.up.annotations.Address in project vertx-zero by silentbalanceyh.

the class MongoWorker method sayMongo.

@Address("ZERO://QUEUE/NATIVE/MONGO")
public void sayMongo(final Message<Envelop> message) {
    final JsonObject data = Ux.getJson(message);
    this.client.insert("DB_TEST", data, res -> {
        if (res.succeeded()) {
            System.out.println(res.result());
            message.reply(Ux.to(data));
        } else {
            res.cause().printStackTrace();
            message.reply(Envelop.ok());
        }
    });
}
Also used : JsonObject(io.vertx.core.json.JsonObject) Address(io.vertx.up.annotations.Address)

Aggregations

Address (io.vertx.up.annotations.Address)14 JsonObject (io.vertx.core.json.JsonObject)13 JsonArray (io.vertx.core.json.JsonArray)1 ResultSet (io.vertx.ext.sql.ResultSet)1