Thursday, 10 May 2012

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();
    }
}

7 comments:

Unknown said...

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

madeinstein said...

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.

KCHsu said...

Can you explain the Dispatcher & Queue ??

madeinstein said...

KCHsu have a look at the TIBCO Rendezvous® Concepts pdf document.

Antonio said...
This comment has been removed by the author.
for IT the said...

great

Radley Co Tad said...

Hi, Great.. Tutorial is just awesome..It is really helpful for a newbie like me.. I am a regular follower of your blog. Really very informative post you shared here. Kindly keep blogging. If anyone wants to become a .Net developer learn from .Net Core Training in Chennai. or learn thru .Net Core Training in Chennai. Nowadays Dot Net has tons of job opportunities on various vertical industry.
or Es6 Training in Chennai. Nowadays JavaScript has tons of job opportunities on various vertical industry.

Post a Comment