Category Archives: TIBCO

TIB/Rendezvous Daemon viewer

A useful tool for checking whether a user/machine is connected to TIBCO RV is to connect to their daemon. The TIBCO RV daemon includes a web browser – simply connect to the following

http://hostname:7580/index.html

Setting the host name to that of the machine you want to inspect (or their ip address).

This will display general information about the installed version of rvd if it’s installed ofcourse. Selecting the Client option will show the daemon’s client connections. For each connection is an Identifier which you can click on to see more details regarding that connection. From this you can also view the Subscriptions, i.e. what topics you’re daemon is listening on.

The Service option will show what service the daemon is connected to as well as all the other hosts that are connected.

Finally there’s the Current Log showing the log from the daemon.

Running tibrvlisten

I keep forgetting this command, so time to blog about it

Occasionally, we’ll want to monitor RV messages being received on our host machine, to do this we can use the tibrvlisten.exe application from the command prompt along with the appropriate arguments. tibrvlisten.exe will filter and display the RV messages as they arrive on the host computer.

An example of use might be

tibrvlisten -service 1234 -network ;123.123.123.123 "mytopics.>"

The -service is the port being used for RV, followed by the IP address of the network it’s on. Note the ; preceding the IP address. Also in this case, I’m filtering what tibrvlisten outputs to the screen by displaying only those messages which start with mytopics. and using the wildcard > symbol.

Minimal steps to create a TIBCO RV message and send it

The previous post was on creating a minimal TIBCO RV listener. So naturally it’s time to look at creating a minimal TIBCO RV “sender”. In other words, creating a message and sending it.

Note: The initial code was take from the C# TIB RV samples, but I wanted to distil these to a quick and simple step by step guide.

For this sample we’ll create a Console application in C# and we’ll assume you are getting the server, network etc. values from some key/value mechanism, whether this is a command line parser or config is down to your specific implementation.

So create a Windows Console project then follow the steps below (the full code will be listed at the end of this rambling)

In case you’ve come to this post without first reading the post on creating a minimal listener, I will repeat a fair amount of code/steps from that post here.

  1. Add references to TIBCO.Rendezvous and ensure that TIBCO.Rendezvous.netmodule resides in the same folder as TIBCO.Rendezvous (just in case you’re not referencing the TIB RV installation itself
  2. For this simple example we’ll hard code a few variables
    string server = arguments["server"];
    string network = arguments["network"];
    string daemon = arguments["daemon"];
    
  3. Next we need to open the Rendezvous environment using

    TIBCO.Rendezvous.Environment.Open();
    

    The above code should be enclosed in a try..catch block, either enclosing all of the following code or if you want the granularity, then each line in essence. For now we’ll just assume it’s all in a try..catch block

  4. We now need to create the transport

    Transport transport = new NetTransport(service, network, daemon);
    
  5. Now it’s time to create the message. The subject is set to “myapp.mysubject” and we add some data to a new field we’ve created named “Data”

    Message message = new Message { SendSubject = "myapp.mysubject" };
    message.AddField("Data", "Some Data");
    
  6. To send the message is simply a case of

    transport.Send(message);
    
  7. Finally when we’ve finished with RV we need to close the environment with

    TIBCO.Rendezvous.Environment.Close();
    

Before we look at the full code, here’s what the listener shows us if we listen to “myapp.>”

2013-11-21 15:58:49 (2013-11-21 15:58:49.281000000Z): subject=myapp.mysubject, message={Data=”Some Data”}

And as promised, the full code is

public void Process(CommandLineArguments arguments)
{
   string service = arguments["server"];
   string network = arguments["network"];
   string daemon = arguments["daemon"];

   try
   {
      TIBCO.Rendezvous.Environment.Open();

      Transport transport = new NetTransport(service, network, daemon);

      Message message = new Message { SendSubject = "myapp.mysubject" };
      message.AddField("Data", "Some Data");
      transport.Send(message);
   }
   catch (Exception e)
   {
      Console.WriteLine(e.Message + "\n\n" + e.StackTrace);
   }
   finally
   {
      TIBCO.Rendezvous.Environment.Close();
   }
}

Minimal steps to create a TIBCO RV listener

Following is a list of the steps (and code) for creating a minimal TIB RV listener which will simply output messages to the console (therefore implementing the same sort of functionality as the tibrvlisten application.

Note: The initial code was take from the C# TIB RV samples, but I wanted to distil these to a quick and simple step by step guide.

For this sample we’ll create a Console application in C# and we’ll assume you are getting the server, network etc. values from some key/value mechanism, whether this is a command line parser or config is down to your specific implementation.

So create a Windows Console project then follow the steps below (the full code will be listed at the end of this rambling)

  1. Add references to TIBCO.Rendezvous and ensure that TIBCO.Rendezvous.netmodule resides in the same folder as TIBCO.Rendezvous (just in case you’re not referencing the TIB RV installation itself
  2. For this simple example we’ll hard code a few variables
    string server = arguments["server"];
    string network = arguments["network"];
    string daemon = arguments["daemon"];
    string topics[] = arguments["topics"].Split(',');
    
  3. Next we need to open the Rendezvous environment using

    TIBCO.Rendezvous.Environment.Open();
    

    The above code should be enclosed in a try..catch block, either enclosing all of the following code or if you want the granularity, then each line in essence. For now we’ll just assume it’s all in a try..catch block

  4. We now need to create the transport

    Transport transport = new NetTransport(service, network, daemon);
    
  5. Now create the listeners and attach a MessageReceived handler to each listener.

    TIBCO.Rendezvous.Listener[] listeners = new TIBCO.Rendezvous.Listener[topics.Length];
    for (int i = 0; i < listeners.Length; i++)
    {
       listeners[i] = new TIBCO.Rendezvous.Listener(Queue.Default, 
                         transport, topics[i], null);
       listeners[i].MessageReceived += OnMessageReceived;
    }
    

    The code for the OnMessageReceived handler looks like

    static void OnMessageReceived(object listener, 
                  MessageReceivedEventArgs messageReceivedEventArgs)
    {
       Message message = messageReceivedEventArgs.Message;
    
       Console.Out.WriteLine("{0}: subject={1}, reply={2}, message={3}",
    	DateTime.Now, message.SendSubject, message.ReplySubject, message);
    
       Console.Out.Flush();
    }
    
  6. Now for this example we’re going to go into a look and just keep calling the Queue.Default.Dispatch method to keep messages dispatching or block whilst no messages exist

    while (true)
    {
       try
       {
          Queue.Default.Dispatch();
       }
       catch (RendezvousException exception)
       {
          Console.Error.WriteLine("Exception dispatching default queue:");
          Console.Error.WriteLine(exception.StackTrace);
          break;
       }
    }
    
  7. Finally when we’ve finished with RV we need to close the environment with

    TIBCO.Rendezvous.Environment.Close();
    

Full code

public void Run(CommandLineArguments arguments)
{
   string service = arguments["server"];
   string network = arguments["network"];
   string daemon = arguments["daemon"];

   string[] topics = arguments["topics"].Split(',');
			
   try
   {
      TIBCO.Rendezvous.Environment.Open();

      Transport transport = new NetTransport(service, network, daemon);

      TIBCO.Rendezvous.Listener[] listeners = new TIBCO.Rendezvous.Listener[topics.Length];
      for (int i = 0; i < listeners.Length; i++)
      {
         listeners[i] = new TIBCO.Rendezvous.Listener(Queue.Default, 
                               transport, topics[i], null);
         listeners[i].MessageReceived += OnMessageReceived;
      }

      while (true)
      {
         try
         {
            Queue.Default.Dispatch();
         }
         catch (RendezvousException exception)
         {
             Console.Error.WriteLine("Exception dispatching default queue:");
             Console.Error.WriteLine(exception.StackTrace);
             break;
         }
      }
   }
   catch (Exception e)
   {
      Console.WriteLine(e.Message + "\n\n" + e.StackTrace);
   }
   finally
   {
      TIBCO.Rendezvous.Environment.Close();
   }
}

static void OnMessageReceived(object listener, 
         MessageReceivedEventArgs messageReceivedEventArgs)
{
   Message message = messageReceivedEventArgs.Message;

   Console.Out.WriteLine("{0}: subject={1}, reply={2}, message={3}",
		DateTime.Now, message.SendSubject, message.ReplySubject, message);

   Console.Out.Flush();
}