adnaan / vertx-go-tcp-eventbus-bridge

A Go Client for the Eclipse Vert.x TCP EventBus Bridge

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

A Go Client for the Eclipse Vert.x TCP EventBus Bridge

This project is a client API for interacting with Eclipse Vert.x applications from Go applications using the TCP EventBus bridge from Vert.x.


You will need the following import:

import (
  // ...
  // ...

and go get

The eventbus package essentially provides 2 types:

  1. eventbus.EventBus that encapsulates the TCP bridge protocol, and
  2. eventbus.Dispatcher that helps receiving messages from the event bus, and dispatch them to Go channels.

Here is an (incomplete) snippet showing the usage of these 2 types:

// Get an event bus connection
eventBus, err := eventbus.NewEventBus("localhost:7000")
if err != nil {
  log.Fatal("Connection to the Vert.x bridge failed: ", err)

// Get a dispatcher for incoming messages
dispatcher := eventbus.NewDispatcher(eventBus)

// Get a queue of length 8 for the messages on 'sample.clock.ticks'
ticks, id, err := dispatcher.Register("sample.clock.ticks", 8)
if err != nil {
  log.Fatal("Registration on sample.clock.ticks failed: ", err)
log.Println("sample.clock.ticks channel registered with ID=", id)

// Print all ticks from a goroutine
go func() {
  for {

// Post messages to 'sample.echo', and expect replies on 'sample.echo.reply'
go func() {
  for {
    <-time.After(time.Second * 3)
    eventBus.SendWithReplyAddress("sample.echo", "sample.echo.reply", nil, map[string]string{
      "source": "Go Client",
      "what": "A tick!",

// Get replies on 'sample.echo.reply'
go func() {
  for reply := range(echoReply) {
    log.Println("Echo, got back: ", reply)


You should read the API documentation to understand all operations, and especially the concurrency assumptions and requirements:

A sample Vert.x / Java application is given in vertx-sample-app/.

It can be used to run against the sample Go client from sample-vertx-go-client/.

Finally, the integration tests in eventbus/integration-test/ can be run using go test in that folder, and the Vert.x / Java application above needs to be running.


Copyright 2016 Julien Ponge

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
See the License for the specific language governing permissions and
limitations under the License.


A Go Client for the Eclipse Vert.x TCP EventBus Bridge

License:Apache License 2.0


Language:Go 90.8%Language:Java 9.2%