Search Results

TIBCO eFTL C# Quick Start

Quick Start Contents


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

Getting Started

  • Download the TIBCO eFTL Messaging SDK for C#. 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.

Building and running samples

Follow the steps below to build and run the C# samples:


> cd <eftl>/samples
> dotnet build Publisher.csproj 
> dotnet build Subscriber.csproj 
> dotnet build SharedSubscriber.csproj 
> dotnet build LastValueSubscriber.csproj


> dotnet bin/x64/Release/netcoreapp2.1/Subscriber.dll
> dotnet bin/x64/Release/netcoreapp2.1/SharedSubscriber.dll
> dotnet bin/x64/Release/netcoreapp2.1/LastValueSubscriber.dll
> dotnet bin/x64/Release/netcoreapp2.1/Publisher.dll

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 C# programs, include the eFTL CLient C# library:


Connect to TIBCO Cloud Messaging

To establish a connection to TIBCO Cloud Messaging, you need the URL and the 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.

Hashtable props = new Hashtable(); 

// Set the password using your authentication key 
props.Add(EFTL.PROPERTY_PASSWORD, "6ee7639011dd67ac79272a0844c16671"); 

// Provide a unique client identifier
props.Add(EFTL.PROPERTY_CLIENT_ID, "abc123"); 

// Connect to TIBCO Cloud Messaging
             new ConnectionListener()); 

class ConnectionListener : IConnectionListener { 
   public void OnConnect(IConnection connection){ 
   public void OnDisconnect(IConnection connection, int code, String reason) {
      Console.WriteLine("disconnected: {0}", reason); 
   public void OnReconnect(IConnection connection) {
   public void OnError(IConnection connection, int code, String reason) {
      Console.WriteLine("error: {0}", reason); 

OnConnect callback

The onConnect callback is invoked after the connection to TIBCO Cloud Messaging is established. The Connection object passed to the onConnect callback can be used for subscribing to messages and publishing messages.

OnDisconnect callback

If the connection cannot be established, or is lost, the onDisconnect callback is invoked.

OnReconnect callback

The onReconnect callback is invoked when the client successfully reconnects to TIBCO Cloud Messaging.

OnError callback

The onError callback is invoked when TIBCO Cloud Messaging sends an error to the client.

Publish Messages

After the clients are connected to TIBCO Cloud Messaging, they can publish messages. To publish messages, use the connection returned in the onConnect callback.

// Create a message 
// Fields and arrays of type string, numeric, date, and sub-messages are used in messages.
IMessage message = connection.CreateMessage(); 
message.SetString("event", "hello");
message.SetString("text": "Hello, World!"); 

// Publish a message to TIBCO Cloud Messaging 
connection.Publish(message, null);

// Publish a message to TIBCO Cloud Messaging
connection.publish(message, new CompletionListener()); 

// To be notified if the publish was successful or if an error occurred, callbacks can be provided.
CompletionListener : ICompletionListener { 
   public void OnCompletion(IMessage message) { 
     Console.WriteLine("publish success\n"); 
   public void OnError(IMessage message, int code, String reason) { 
      Console.WriteLine("publish error: {0}", reason); 

Receive Messages

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

// 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 
connection.subscribe("{\"event\":\"hello\"}", "hello", new SubscriptionListener()); 

Class SubscriptionListener : ISubscriptionListener { 
   public void OnMessage(IMessage[] messages){ 
      Console.WriteLine("message received: {0}", message.GetString("text")); 
   public void OnSubscribe(String subscription) {
   public void OnError(String subscription, int code, String reason) {
      Console.WriteLine("subscription error: {0}", reason); 

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.

onMessage callback

The onMessage callback is invoked when the content of a published message matches the subscription’s matcher.

onError callback

The onError callback is invoked when an error occurs while registering the subscription, typically because of an invalid matcher or invalid durable.