This project is read-only.

Quick Start with Amqp.Net Lite

Create a topic and a subscription on the topic through the Azure portal or through the Service Bus client SDK (using NamespaceManager) (refer to the Service Bus documentation for details).

Send a message to a Azure Service Bus topic:
var amqpConnection = new Connection(new Address 
amqpConnection.OnClosed += this.ConnectionClosed;  
var amqpSession = new Session(this.AmqpConnection);  
amqpSession.OnClosed += this.SessionClosed;  
SenderLink amqpSender = new SenderLink(amqpSession, 
       "send-link/in/t0000", // unique name for all links from this client 
       "/in/t0000"); // Service Bus entity name 
amqpSender.OnClosed += this.SenderLinkClosed;  
var message = new Message();  
message.Properties = new Properties();  
message.Properties.Subject = "mymessagetype";  
message.ApplicationProperties = new ApplicationProperties();  
message.ApplicationProperties["MyProperty"] = "Hello World!";  
amqpSender.Send(message, MessageOutcomeCallback, null);  

Receive messages from a Azure Service Bus subscription of the topic:
// Open connection and session as per above (or reuse the same connection/session as for send)
var amqpReceiver = new ReceiverLink(this.AmqpSession, 
    "receive-linkout/t0000/Subscriptions/s0000", // unique name for all links from this client
    "out/t0000/Subscriptions/s0000"); // Service Bus entity name
amqpReceiver.OnClosed += this.ReceiverLinkClosed;
amqpReceiver.Start(5, OnMessageCallback);


void OnMessageCallback(ReceiverLink receiver, Message message)
    var value = message.ApplicationProperties["MyProperty"];
    // Do something with the value

The OBD Recorder sample further illustrates how to use this library in an end-to-end scenario.

  1. Reserved characters (i.e. '/') in connection strings must be URL encoded. See Issue 1.

Last edited Jul 29, 2014 at 5:46 AM by xinchen, version 1