public class EventBusHandler
extends java.lang.Object
If the header "x-sync" is set to "true", then the handler waits for an event reply before returning the response. In this case, the response contains the replied JSON, if any.
Requests are forwarded in the form:
{
"uri": "http://...",
"method": "PUT",
"headers": [
[ "name", "value" ],
[ "name", "value" ]
],
"payload": {
"hello": "world"
}
}
Payload is a JsonObject in case of application/json content type, a string in case of text/* content type, a
base64 binary string otherwise.
Replies from clients have the same structure, without the uri.1
| Modifier and Type | Field and Description |
|---|---|
static int |
ACCEPTED |
static java.lang.String |
APPLICATION_JSON |
static int |
BAD_REQUEST |
static java.lang.String |
CONTENT_TYPE |
static int |
GATEWAY_TIMEOUT |
static java.lang.String |
HEADERS |
static java.lang.String |
METHOD |
static java.lang.String |
PAYLOAD |
static java.lang.String |
SYNC |
static java.lang.String |
TEXT |
static int |
TIMEOUT |
static java.lang.String |
URI |
| Constructor and Description |
|---|
EventBusHandler(io.vertx.core.Vertx vertx,
java.lang.String apiPath,
java.lang.String sockPath,
java.lang.String addressPrefix,
java.lang.String addressPathPattern)
Constructs and configures the handler.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
handle(io.vertx.core.http.HttpServerRequest request) |
void |
install(io.vertx.ext.web.Router router)
Configures and binds the SockJS bridge to an HttpServer.
|
void |
setEventbusBridgePingInterval(java.lang.Long eventbusBridgePingInterval)
Sets the ping_interval passed to the eventbus bridge.
|
public static final int ACCEPTED
public static final java.lang.String SYNC
public static final java.lang.String TEXT
public static final java.lang.String METHOD
public static final int BAD_REQUEST
public static final java.lang.String CONTENT_TYPE
public static final java.lang.String APPLICATION_JSON
public static final java.lang.String PAYLOAD
public static final java.lang.String URI
public static final java.lang.String HEADERS
public static final int TIMEOUT
public static final int GATEWAY_TIMEOUT
public EventBusHandler(io.vertx.core.Vertx vertx,
java.lang.String apiPath,
java.lang.String sockPath,
java.lang.String addressPrefix,
java.lang.String addressPathPattern)
vertx - vertxapiPath - The full URI path where to access the event api. E.g. /context/server/event/v1/.sockPath - The full URI path of the SockJS endpoint to configure.addressPrefix - The prefix used for the event bus addresses the handlers sends requests to. E.g. event/addressPathPattern - A pattern to extract the address from the URI. This pattern is appended to the apiPath and must have a group.
For example, a pattern hello/(world/[^/]+)/.* will forward requests on
/context/server/event/v1/hello/world/foo/bar to address event/world/foo.public boolean handle(io.vertx.core.http.HttpServerRequest request)
public void install(io.vertx.ext.web.Router router)
router - routerpublic void setEventbusBridgePingInterval(java.lang.Long eventbusBridgePingInterval)
install(io.vertx.ext.web.Router)eventbusBridgePingInterval - Interval in milliseconds or null to use the default interval of the eventbus bridge (10 seconds)