Class EventbusTcpBridge
- All Implemented Interfaces:
io.vertx.core.Verticle
It creates Router
using vertx, which handles HTTP-Requests coming to the HTTP-Server.
The EventBusBridge by default works after the deny-any-principle, which means that any message
which is not permitted explicitly will be denied (reply messages are an exception).
To permit the desired messages for the frontend to go through you have to configure
SockJSBridgeOptions
and mount them as a SubRouter to the Router.
You have to configure the following options:
- httpServerOptions - the HttpServerOptions to configure the HTTP-Server
- defaultSockJSBridgeOptions - the SockJSBridgeOptions to configure rules to allow messages to go through
To define rules for messages to be allowed through you have to add
new PermittedOptions()
to the sockJSBridgeOptions.
You can either do that in the third constructor by passing new SockJSBridgeOptions
as parameter or modify the defaultSockJSBridgeOptions and add your rules there.
An example looks like this:
SockJSBridgeOptions defaultSockJSBridgeOptions = new SockJSBridgeOptions()
.addInboundPermitted(new PermittedOptions()
.setAddress(Address.incoming(<YourClass>.class, "<method>")))
.addOutboundPermitted(new PermittedOptions()
.setAddress(Address.outgoing(<YourClass>.class, "<method>)));
To support that the one can send data type specific data on the outbound address vertx supports regex.
You can add a regex to new PermittedOptions()
.
An example looks like this:
SockJSBridgeOptions sockJSBridgeOptions = new SockJSBridgeOptions()
.addOutboundPermitted(new PermittedOptions().setAddressRegex("(<Address>)(\/(\S+))?"));
Which results in permission granted to all messages to the given address optionally suffixed with e.g. "/className.- See Also:
- README.md for more information
-
Field Summary
Fields inherited from class io.vertx.core.AbstractVerticle
context, vertx
-
Constructor Summary
ConstructorsConstructorDescriptionIf this constructor is used all, settings have to be specified in the config file.EventbusTcpBridge(String host, int port, List<String> inboundPermitted, List<String> outboundPermitted)
This constructor supplies default options and uses the defaultSockJSBridgeOptions for the applied rules. -
Method Summary
Methods inherited from class io.vertx.core.AbstractVerticle
config, deploymentID, getVertx, init, processArgs, start, stop, stop
-
Constructor Details
-
EventbusTcpBridge
public EventbusTcpBridge(String host, int port, List<String> inboundPermitted, List<String> outboundPermitted)This constructor supplies default options and uses the defaultSockJSBridgeOptions for the applied rules.- Parameters:
host
- the ip address of the host on which the HTTP-Server should runport
- the port on which the HTTP-Server should listeninboundPermitted
- the permitted eventbus addresses for inbound connectionsoutboundPermitted
- the permitted eventbus addresses for outbound connections
-
EventbusTcpBridge
public EventbusTcpBridge()If this constructor is used all, settings have to be specified in the config file.
-
-
Method Details
-
start
- Specified by:
start
in interfaceio.vertx.core.Verticle
- Overrides:
start
in classio.vertx.core.AbstractVerticle
-