开发者

.Net Messaging & STOMP Protocol

I have a doubt regarding .net messaging & its compatibility with other open protocols out there. I would like to know if .net m开发者_运维知识库essaging API capable of working with STOMP protocol? How do i make use of this protocol? is there any specific library out there I need to use?

thanks for sharing your experience and ideas.


If your goal is to send messages from a .NET language, consider leveraging the Apache ActiveMQ NMS library for .NET. They claim to use a single API to connect to multiple different providers.

Currently, the following providers are available:

  • ActiveMQ which connects using OpenWire to an ActiveMQ Message Broker.
  • STOMP which connects to any STOMP Broker.

Their site linked above has the downloads, and links to articles on how to get started on the common messaging scenarios.


At the root of it, STOMP appears to be TCP-based messaging with its set of commands and control characters.

There's nothing in .NET that should give you any doubts about not being able to build an application or library using this protocol. If you were building a .NET STOMP library from scratch, you'd have to leverage System.Net.Sockets. Here's some sample C# code.

Byte[] bytesSent = Encoding.ASCII.GetBytes(someStringMessage);

// Create a socket connection with the specified server and port.
Socket s = ConnectSocket("192.168.0.101", somePort);

// If the socket could not get a connection, then return false.
if (s == null)
    return false;

// Send message to the destination.
s.Send(bytesSent, bytesSent.Length, 0);

// Receive the response back
int bytes = 0;
s.ReceiveTimeout = 3000;
bytes = s.Receive(bytesReceived, bytesReceived.Length, 0);
string page = Encoding.ASCII.GetString(bytesReceived, 0, bytes);
s.Close();

What doubts did you have? Perhaps edit your question with any concerns?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜