Vert.x-tcp-eventbus-bridge is a TCP bridge to Vert.x EventBus.

To use this project, add the following dependency to the dependencies section of your build descriptor:

  • Maven (in your pom.xml):

<dependency>
  <groupId>io.vertx</groupId>
  <artifactId>vertx-tcp-eventbus-bridge</artifactId>
  <version>3.2.0</version>
</dependency>
  • Gradle (in your build.gradle file):

compile 'io.vertx:vertx-tcp-eventbus-bridge:3.2.0'

The TCP EventBus bridge as its name states is a bridge built on top of TCP, meaning that any application able to create sockets can use the EventBus from a remote Vert.x instance.

The protocol has been kept as simple as possible and communications use Frames both ways. A typical frame looks like this:

<Length:Int32>{type: String, headers: Object, body: Object}

The wire format is 4 bytes for the message length followed by a json document (there is no need to remove new lines or white space.

Every received frame with a reply address will return a frame. In case of error even if there is no reply address the server might return a message, in this case the type will be "err".

An example NodeJS client is available in the source of the project, this client uses the same API as the SockJS counter part so it will make it easier to switch implementations.

The use case for the TCP bridge vs the SockJS bridge if for applications that are more constrained in resources and need to be lightweight since the whole HTTP WebSockets is replaced with plain TCP sockets.

An example on how to get started with this bridge could be:

  • [source,groovy]

import io.vertx.ext.groovy.eventbus.bridge.tcp.TcpEventBusBridge

def bridge = TcpEventBusBridge.create(vertx, [
  inboundPermitteds:[
    [
      address:"in"
    ]
  ],
  outboundPermitteds:[
    [
      address:"out"
    ]
  ]
])

bridge.listen(7000, { res ->
  if (res.succeeded()) {
    // succeed...
  } else {
    // fail...
  }
})