public class EventBusHandler extends Object implements ConfigurationResourceObserver
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 String |
APPLICATION_JSON |
static int |
BAD_REQUEST |
static String |
CONTENT_TYPE |
static int |
GATEWAY_TIMEOUT |
static String |
HEADERS |
static String |
METHOD |
static String |
PAYLOAD |
static String |
SYNC |
static String |
TEXT |
static int |
TIMEOUT |
static String |
URI |
| Constructor and Description |
|---|
EventBusHandler(io.vertx.core.Vertx vertx,
String apiPath,
String sockPath,
String addressPrefix,
String addressPathPattern) |
EventBusHandler(io.vertx.core.Vertx vertx,
String apiPath,
String sockPath,
String addressPrefix,
String addressPathPattern,
ConfigurationResourceManager configurationResourceManager,
String configResourceUri)
Constructs and configures the handler.
|
| Modifier and Type | Method and Description |
|---|---|
io.vertx.ext.web.handler.sockjs.SockJSHandlerOptions |
getSockJSHandlerOptions() |
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 |
resourceChanged(String resourceUri,
String resource)
Gets called when the resource with uri
resourceUri has been changed. |
void |
resourceRemoved(String resourceUri)
Gets called when the resource with uri
resourceUri has been removed. |
void |
setEventbusBridgeMaxAddressLength(Integer eventbusBridgeMaxAddressLength)
Sets the maximum address length passed to the eventbus bridge.
|
void |
setEventbusBridgeMaxHandlersPerSocket(Integer eventbusBridgeMaxHandlersPerSocket)
Sets the max handlers per socket passed to the eventbus bridge.
|
void |
setEventbusBridgePingInterval(Long eventbusBridgePingInterval)
Sets the ping_interval passed to the eventbus bridge.
|
void |
setEventbusBridgeReplyTimeout(Long eventbusBridgeReplyTimeout)
Sets the reply timeout passed to the eventbus bridge.
|
void |
setSockJSHandlerOptions(io.vertx.ext.web.handler.sockjs.SockJSHandlerOptions sockJSHandlerOptions)
Sets the
SockJSHandlerOptions to be used for the websocket connections. |
public static final int ACCEPTED
public static final String SYNC
public static final String TEXT
public static final String METHOD
public static final int BAD_REQUEST
public static final String CONTENT_TYPE
public static final String APPLICATION_JSON
public static final String PAYLOAD
public static final String URI
public static final String HEADERS
public static final int TIMEOUT
public static final int GATEWAY_TIMEOUT
public EventBusHandler(io.vertx.core.Vertx vertx,
String apiPath,
String sockPath,
String addressPrefix,
String addressPathPattern)
public EventBusHandler(io.vertx.core.Vertx vertx,
String apiPath,
String sockPath,
String addressPrefix,
String addressPathPattern,
ConfigurationResourceManager configurationResourceManager,
String configResourceUri)
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.configurationResourceManager - The ConfigurationResourceManager used to get notifications on resource updatesconfigResourceUri - The full URI path of the configuration resourcepublic boolean handle(io.vertx.core.http.HttpServerRequest request)
public void install(io.vertx.ext.web.Router router)
router - routerpublic void resourceChanged(String resourceUri, String resource)
ConfigurationResourceObserverresourceUri has been changed.
The changed resource is provided in the resource parameter.resourceChanged in interface ConfigurationResourceObserverresourceUri - the uri of the resource that has been changedresource - the resource including the changespublic void resourceRemoved(String resourceUri)
ConfigurationResourceObserverresourceUri has been removed.resourceRemoved in interface ConfigurationResourceObserverresourceUri - the uri of the resource that has been removedpublic void setEventbusBridgePingInterval(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)public void setEventbusBridgeReplyTimeout(Long eventbusBridgeReplyTimeout)
install(io.vertx.ext.web.Router)eventbusBridgeReplyTimeout - Timeout in milliseconds or null to use the default reply timeout of the eventbus bridge (30 seconds)public void setEventbusBridgeMaxAddressLength(Integer eventbusBridgeMaxAddressLength)
install(io.vertx.ext.web.Router)eventbusBridgeMaxAddressLength - Maximum address length or null to use the default value of the eventbus bridge (200)public void setEventbusBridgeMaxHandlersPerSocket(Integer eventbusBridgeMaxHandlersPerSocket)
install(io.vertx.ext.web.Router)eventbusBridgeMaxHandlersPerSocket - Maximum handlers per socket or null to use the default value of the eventbus bridge (1000)public void setSockJSHandlerOptions(io.vertx.ext.web.handler.sockjs.SockJSHandlerOptions sockJSHandlerOptions)
SockJSHandlerOptions to be used for the websocket connections.
Set these options before calling install(io.vertx.ext.web.Router)sockJSHandlerOptions - SockJSHandlerOptions to be used. Default SockJSHandlerOptions are used when null providedpublic io.vertx.ext.web.handler.sockjs.SockJSHandlerOptions getSockJSHandlerOptions()
Copyright © 2016–2018. All rights reserved.