Search in sources :

Example 1 with EventMessage

use of ren.yale.java.event.EventMessage in project Summer by yale8848.

the class Hello method h3.

@GET
@Path("/async")
public void h3(@Context HttpServerResponse response, @Context Vertx vertx) {
    vertx.eventBus().send("user", EventMessage.message("bob").setKey("name"), message -> {
        EventMessage eventMessage = (EventMessage) message.result().body();
        if (eventMessage.isSuccess()) {
            String ret = String.format("name:%s,age:%d", eventMessage.getMessage(), 18);
            response.end(ret);
        } else {
            response.end("error");
        }
    });
}
Also used : EventMessage(ren.yale.java.event.EventMessage)

Example 2 with EventMessage

use of ren.yale.java.event.EventMessage in project Summer by yale8848.

the class TestService method test.

public SummerResponse test(Vertx vertx, RoutingContext routingContext) {
    EventBus eb = vertx.eventBus();
    EventMessage eventMessage = EventMessage.message(null);
    eventMessage.setKey("68257");
    return SummerResponse.fail().message("bbb");
}
Also used : EventMessage(ren.yale.java.event.EventMessage) EventBus(io.vertx.core.eventbus.EventBus)

Example 3 with EventMessage

use of ren.yale.java.event.EventMessage in project Summer by yale8848.

the class DXHResource method dxh.

@Path("/dxh/{dxhv}")
@GET
public void dxh(@PathParam("dxhv") String dxh, @Context Vertx vertx, @Context HttpServerResponse response) {
    dxh = "8454005";
    // WebClient client = WebClient.create(vertx);
    // HttpUtils.oneDXH(client,response,dxh,vertx);
    // response.end(dxh);
    /*      try {
            EventBus eb = vertx.eventBus();
            EventMessage eventMessage=EventMessage.message(null);
            eventMessage.setKey("68257");
            Message<EventMessage> reply = awaitResult(h -> eb.send("aaa", eventMessage, h));

            //Message<EventMessage> reply1 = awaitResult(h -> eb.send("aaa", eventMessage, h));
            response.end(reply.body().getMessage());
        }catch (Exception e){
            response.end(e.getMessage());
        }*/
    EventBus eb = vertx.eventBus();
    EventMessage eventMessage = EventMessage.message(null);
    eventMessage.setKey("68257");
// Message<EventMessage> reply = awaitResult(h -> eb.send("aaa", eventMessage, h));
// Message<EventMessage> reply1 = awaitResult(h -> eb.send("aaa", eventMessage, h));
// response.end(reply.body().getMessage());
}
Also used : EventMessage(ren.yale.java.event.EventMessage) EventBus(io.vertx.core.eventbus.EventBus) Path(javax.ws.rs.Path) GET(javax.ws.rs.GET)

Example 4 with EventMessage

use of ren.yale.java.event.EventMessage in project Summer by yale8848.

the class MyVerticle method start.

@Override
public void start() throws Exception {
    vertx.eventBus().consumer("user", message -> {
        EventMessage eventMessage = (EventMessage) message.body();
        eventMessage.success(true);
        eventMessage.setMessage("Hello " + eventMessage.getObject());
        message.reply(eventMessage);
    });
    vertx.fileSystem().readFile("dev/dbt.json", bufferAsyncResult -> {
        if (bufferAsyncResult.succeeded()) {
            JsonObject jsonObject = bufferAsyncResult.result().toJsonObject().getJsonObject("reader");
            jdbcReader = JDBCClient.createShared(vertx, jsonObject, "reader");
            jdbcReader.getConnection(sqlConnectionAsyncResult -> {
                if (sqlConnectionAsyncResult.succeeded()) {
                    LOGGER.info("+++++ db success");
                    SQLConnection sqlConnection = sqlConnectionAsyncResult.result();
                    sqlConnection.query(new SummerSQL().SELECT("*").FROM("db_test.tb_test").toString(), resultSetAsyncResult -> {
                        if (resultSetAsyncResult.succeeded()) {
                            List<DBTest> tests = ResultSetMapper.create().camelName().mapperList(resultSetAsyncResult.result(), DBTest.class);
                        }
                        sqlConnection.close();
                    });
                } else {
                }
            });
        }
    });
}
Also used : DBTest(ren.yale.java.bean.DBTest) EventMessage(ren.yale.java.event.EventMessage) SQLConnection(io.vertx.ext.sql.SQLConnection) JsonObject(io.vertx.core.json.JsonObject) SummerSQL(ren.yale.java.sql.SummerSQL)

Aggregations

EventMessage (ren.yale.java.event.EventMessage)4 EventBus (io.vertx.core.eventbus.EventBus)2 JsonObject (io.vertx.core.json.JsonObject)1 SQLConnection (io.vertx.ext.sql.SQLConnection)1 GET (javax.ws.rs.GET)1 Path (javax.ws.rs.Path)1 DBTest (ren.yale.java.bean.DBTest)1 SummerSQL (ren.yale.java.sql.SummerSQL)1