728x90
728x170

우선 TIBCO.Rendezvous.dll 을 참조 추가합니다.

Tibco Rendezvous 를 설치를 위해서는 라이센스 구매가 필요합니다.

Receiver.cs

class Receiver
{
    public void Run()
    {
        TIBCO.Rendezvous.Environment.Open();
        var service      = "7500";
        var network      = ";239.255.0.1";
        var daemon       = "tcp:7500";
        var subject      = "TEST";
        
        Transport transport = new NetTransport(port, network, daemon);
        
        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.cs

class Publisher
{
    public void Run()
    {
        TIBCO.Rendezvous.Environment.Open();
        var service      = "7500";
        var network      = ";239.255.0.1";
        var daemon       = "tcp:7500";
        var subject      = "TEST";
        
        var transport = new NetTransport(port, network, daemon);
        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();
    }
}

 

728x90
그리드형
Posted by kjun.kr
,