Search Results

TIBCO eFTL Go Quick Start

Quick Start Contents


This quick start guide is intended to provide basic instructions for writing Go applications for TIBCO eFTL. It focuses on a collection of sample applications included in the TIBCO eFTL Messaging SDK for Go.

Getting Started

  • Download the TIBCO eFTL Messaging SDK for Go. This guide will refer to your eFTL installation location as <eftl>.
  • Obtain a URL and authentication key from your TIBCO Cloud Messaging account.
  • In the sample application source files, replace the placeholders TIBCO-CLOUD-MESSAGING-URL and TIBCO-CLOUD-MESSAGING-KEY with your account URL and authentication key.


The godoc utility can be used to serve up the TIBCO documentation for Go:

  1. Set GOPATH to <eftl>.
  2. Run go get
  3. Run godoc as a web server: godoc -http=:6060
  4. Browse to http://localhost:6060/pkg/

Building and running samples

Follow the steps below to build and run the Go samples.


Linux and macOS:

> export GOPATH=<eftl>
> go get
> go install


> set GOPATH=<eftl>
> go get
> go install


Linux and macOS

> $GOPATH/bin/subscriber
> $GOPATH/bin/sharedSubscriber
> $GOPATH/bin/lastValueSubscriber
> $GOPATH/bin/publisher


> %GOPATH%\bin\subscriber.exe
> %GOPATH%\bin\sharedSubscriber.exe
> %GOPATH%\bin\lastValueSubscriber.exe
> %GOPATH%\bin\publisher.exe

Description of sample applications


Basic publisher program that demonstrates the use of publishing eFTL messages.


Basic subscriber program that demonstrates the use of subscribing to eFTL messages.

Run the Subscriber and Publisher at the same time to demonstrate real-time messaging. Stop the Subscriber, run the Publisher, and restart the Subscriber to demonstrate persistence.


Basic subscriber program that demonstrates the use of subscribing to eFTL messages using a shared durable.

Run multiple instances of the SharedSubscriber and one Publisher to demonstrate message load-balancing across a shared durable subscription.


Basic subscriber program that demonstrates the use of subscribing to eFTL messages using a last-value durable.

Start and stop the LastValueSubscriber. Run the Publisher several times. Re-start the LastValueSubscriber to receive only the last published message to demonstrate the use of a last-value durable subscription.

Using the eFTL SDK

For Go programs, include the eFTL CLient Go library:

import ""

Install Websocket dependency

You must also download and install the WebSockets dependency package:

go get

Connect to TIBCO Cloud Messaging

To establish a connection to TIBCO Cloud Messaging, you need the URL and authentication key. Authentication keys can be obtained only from your TIBCO Cloud Messaging account page on the Authentication key tab. The eFTL client uses the URL to connect to the library. The authentication key is the password used by the eFTL client library to authenticate itself.

Client Identifiers

You must also provide a unique identifier for your client so that it can receive any missed messages while it is disconnected. Note: Client identifiers must be unique; no two clients with the same identifier can be connected simultaneously.

// Create connection options 
opts := &eftl.Options{
   Password: "6ee7639011dd67ac79272a0844c16671",
   ClientID: "abc123", 

// Create channel on which to receive connection errors 
errChan := make(chan error, 1) 

// Connect to TIBCO Cloud Messaging 
conn, err := eftl.Connect("wss://",
                          opts, errChan) 
if err != nil {
   log.Println("connect failed: ", err) 

// Disconnect from TIBCO Cloud Messaging when done 
defer conn.Disconnect() 

// listen for connection errors 
for err := range errChan { 
    log.Println("connection error: ", err) 

Publish Messages

After clients are connected to TIBCO Cloud Messaging, they can publish messages. To publish messages, use the connection returned by the Connect method.

// Publish a message to TIBCO Cloud Messaging
// Fields and arrays of type string, numeric, date, and sub-messages are used in messages.
err := conn.Publish(eftl.Message{
   "event": "hello",
   "text": "Hello, World!", 
if err != nil {
   log.Println("publish failed: ", err) 

Receive Messages

After the clients are connected to TIBCO Cloud Messaging, they can create one or more subscriptions to receive messages of interest. You subscribe to messages by matching on the message fields that are of your interest. Use the connection returned by the Connect method to register subscriptions.

// Channel on which messages are received 
msgChan := make(chan eftl.Message, 100)

// Create a subscription in TIBCO Cloud Messaging 
// This subscription matches all published messages that contain a 
// field named "event" with a value of "hello" 
// This subscription also sets the durable name to "hello" which allows 
// the client to receive messages that were published while disconnected 
sub, err := conn.Subscribe("{\"event\":\"hello\"}", "hello", msgChan) 
if err != nil {
   log.Println("subscribe failed: ", err) 

// Unsubscribe from messages when done 
defer conn.Unsubscribe(sub) 

// Listen for messages 
for msg := range msgChan {
   log.Println("received message: ", msg) 

Matcher field

The matcher field specifies the messages that are to be received by matching their content. In this case, the subscription receives all published messages containing a field named “event” whose value is “hello”.

Durable field

The durable field is the unique subscription name used by TIBCO Cloud Messaging to store messages for the client when the client is not connected.