Vert.x provide event but to process async request workflow, Zero also support standard Event Bus
The sender will send the data processed to EventBus
package org.exmaple;
import io.vertx.core.json.JsonObject;
import io.vertx.up.annotations.Address;
import io.vertx.up.annotations.EndPoint;
import javax.ws.rs.BodyParam;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
@Path("/up/example")
@EndPoint
public class ZeroSender {
@Path("/event")
@POST
@Address("ZERO://EVENT")
public JsonObject sayEvent(
@BodyParam final JsonObject data) {
return data;
}
}
package org.exmaple;
import io.vertx.core.json.JsonObject;
import io.vertx.up.annotations.Address;
import io.vertx.up.annotations.Queue;
import io.vertx.up.commune.Envelop;
@Queue
public class ZeroConsumer {
@Address("ZERO://EVENT")
public Envelop reply(final Envelop message) {
// JsonObject could be extract directly, not needed to pass T.class
final JsonObject data = message.data();
return Envelop.success(data);
}
}
...
Vert.x zero has found 3 incoming address from the system. Incoming address list as below:
Addr : ZERO://EVENT
...
[ ZERO ] ( Uri Register ) "/up/example/event" has been deployed by ZeroHttpAgent, ...
curl -H "Content-Type:application/json" -X POST --data '{"name":"Lang","email":"[email protected]"}' \
http://localhost:6083/up/example/event
{"brief":"OK","status":200,"data":{"name":"Lang","email":"[email protected]"}}
-
The address of Sender/Consumer must be one to one matching.
-
The consumer class only support following two method signature:
// Java Style public Envelop reply(final Envelop message) // Vert.x Style public void async(final Message<Envelop> message)