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
그리드형
'C#' 카테고리의 다른 글
[C#/Rendezvous] 에러 - "TIBCO.Rendezvous.netmodule" cannot be found (0) | 2023.05.03 |
---|---|
[C#] euc-kr 인코딩 에러 - No data is available for encoding 51949. For information on defining a custom encoding, see the documentation for the Encoding.RegisterProvider method. (0) | 2023.05.03 |
[C#] C# 11 - file access modifier (0) | 2023.04.01 |
[C#] C# 11 - 복수 라인 처리 (0) | 2023.03.30 |
[C#] 패턴 매칭 (0) | 2023.03.28 |