Code-Sharp / StompSharp

C# (.net) Stomp Client.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

StompSharp

C# (.net) Stomp Client.

Master Provider
Build Status Mono CI Provided by travis-ci

Usage

Registering to messages :

using (IStompClient client = new StompClient("localhost", 61613))
{
    var autoAck = client.SubscriptionBehaviors.AutoAcknowledge;
    using (IDestination<IMessage> destination = client.GetDestination("/queue/a",autoAck))
    {
        using (destination.IncommingMessages.Subscribe(Console.WriteLine))
        {
            Console.WriteLine("Messages are written to console. Press any key to unsubscribe and exit.");
            Console.ReadKey();
        }        
    }
}

Please note that you can change a subscription behavior from auto, client, client-individual.

Sending messages :

using (IStompClient client = new StompClient("localhost", 61613))
{
    var autoAck = client.SubscriptionBehaviors.AutoAcknowledge;
    using (IDestination<IMessage> destination = client.GetDestination("/queue/a",autoAck))
    {
        var messageToSend = new BodyOutgoingMessage(new byte[1024]);
        await destination.SendAsync(messageToSend, NoReceiptBehavior.Default);
    }
}

The task that returned from SendAsync will complete when the message is sent to the server, You can switch to ReceiptBehavior and then the task will be completed when a receipt is received from the server.

About

C# (.net) Stomp Client.

License:MIT License


Languages

Language:C# 99.5%Language:Shell 0.5%