Tibco Rendezvous (tibrv) C# .Net example

This is an example of broadcast messaging using TIBCO Rendezvous.

You can find more information about queue, dispatcher, transport and other rendezvous concepts in the TIBCO Rendezvous® Concepts pdf documentation.

Command Line:

Receiving messages

tibrvlisten –service <port> -network "<ip-address>" –daemon <port> "<subject>"
tibrvlisten –service <port> -network ";<multicast-ip-address>" –daemon <port> "<subject>"

tibrvlisten -service 7500 -network "192.168.xx.xxx" -daemon 7500 "ME.TEST"
tibrvlisten -service 7500 -network "192.168.xx.xxx" -daemon 7500 "ME.>"

Publishing messages

tibrvsend –service <port> -network "<ip-address>" –daemon <port> "<subject>" "<your-message>"

tibrvsend -service 7500 -network "192.168.xx.xxx" -daemon 7500 "ME.TEST" "Hello World"


Local Daemon Webpage

http://localhost:7580/


C# Example:

Add Reference to TIBCO.Rendezvous.dll

Receiver

class Receiver
{
    public void Run()
    {
        TIBCO.Rendezvous.Environment.Open();
        var subject = "ME.TEST";
        var network = "192.168.xx.xxx";
        var port = "7500";
        Transport transport = new NetTransport(port, network, port);
        Listener listener = new Listener(
                Queue.Default,
                transport,
                subject,
                new object()
                );
        listener.MessageReceived += new MessageReceivedEventHandler(listener_MessageReceived);
        var dispacher = new Dispatcher(listener.Queue);
        dispacher.Join();
        Console.WriteLine("Client running..");
        Console.ReadKey();
        TIBCO.Rendezvous.Environment.Close();
    }
    void listener_MessageReceived(object listener, MessageReceivedEventArgs messageReceivedEventArgs)
    {
        Console.WriteLine(messageReceivedEventArgs.Message.GetField("Test").Value);
    }
    static void Main(string[] args)
    {
        new Receiver().Run();
    }
}

Publisher

class Publisher
{
    public void Run()
    {
        TIBCO.Rendezvous.Environment.Open();
        var subject = "ME.TEST";
        var network = "192.168.xx.xxx";
        var port = "7500";
        var transport = new NetTransport(port, network, port);
        Console.WriteLine("Server running..");
        Console.WriteLine("Press x to exit or any other key to send message");
        while (true)
        {
            var m = new Message();
            m.SendSubject = subject;
            m.AddField("Test", "TestValue");
            transport.Send(m);
            var line = Console.ReadLine();
            if (line.ToUpper().Equals("X")) break;
        }
        TIBCO.Rendezvous.Environment.Close();
    }
    static void Main(string[] args)
    {
        new Publisher().Run();
    }
}

Comments

  1. Hi,

    I'd try to do the test and I got the error:

    "Could not load file or assembly 'TIBCO.Rendezvous, Version=1.0.4002.32096, Culture=neutral, PublicKeyToken=1a696d1f90f6158a' or one of its dependencies. An attempt was made to load a program with an incorrect format."

    I'm using .Net Framework 4.0 and Tibco Rendezvous 8.3.1.

    Do you know what I'm doing wrong ?

    Thanks

    ReplyDelete
  2. Try changing platform to x86 in Configuration Manager. Looks like Tibco dll's don't support 64bit architecture - or at least the version I'm using.

    ReplyDelete
  3. Can you explain the Dispatcher & Queue ??

    ReplyDelete
  4. This comment has been removed by the author.

    ReplyDelete
  5. This comment has been removed by the author.

    ReplyDelete

Post a Comment

Popular posts from this blog

Parse XML to dynamic object in C#