Service Bus messaging samples

The Service Bus messaging samples demonstrate key features in Service Bus messaging (cloud service) and Service Bus for Windows Server. This article categorizes and describes the samples available, with links to each.

Note

Service Bus samples are not installed with the SDK. To obtain the samples, visit the Azure SDK samples page.

Additionally, there is an updated set of Service Bus messaging samples here (as of this writing, they are not described in this article).

For relay samples, see Service Bus relay samples.

Service Bus messaging

The following samples illustrate how to write applications that use Service Bus messaging.

Note that the messaging samples require a connection string to access your Service Bus namespace.

To obtain a connection string for Azure Service Bus

  1. Log on to the Azure portal.
  2. In the left-hand column, click Service Bus.
  3. Click the name of your namespace in the list.
  4. In the namespace blade, click Shared access policies.
  5. In the Shared access policies blade, click RootManageSharedAccessKey.
  6. Copy the connection string to the clipboard.

To obtain a connection string for Service Bus for Windows Server

  1. Run the following PowerShell cmdlet:

     get-sbClientConfiguration
    
  2. Paste the connection string into the App.config file for the sample.

Getting started samples

These samples describe basic messaging functionality.

Sample Name Description Minimum SDK Version Availability
Getting Started: Messaging with Queues Demonstrates how to use Microsoft Azure Service Bus to send and receive messages from a queue. 1.8 Microsoft Azure Service Bus; Service Bus for Windows Server
Getting Started: Messaging With Topics Demonstrates how to use Microsoft Azure Service Bus to send and receive messages from a topic with multiple subscriptions. 1.8 Microsoft Azure Service Bus; Service Bus for Windows Server

Exploring features

The following samples demonstrate various features of Service Bus.

Sample Name Description Minimum SDK Version Availability
HTTP Token Providers Demonstrates the different ways of authenticating an HTTP/REST client with Service Bus. 2.1 Microsoft Azure Service Bus; Service Bus for Windows Server
Service Bus HTTP Client Demonstrates how to send messages to and receive messages from Service Bus via HTTP/REST. 2.3 Microsoft Azure Service Bus; Service Bus for Windows Server
Service Bus Autoforwarding Demonstrates how to automatically forward messages from a queue, subscription, or deadletter queue into another queue or topic. It also demonstrates how to send a message into a queue or topic via a transfer queue. 2.3 Microsoft Azure Service Bus; Service Bus for Windows Server
Brokered Messaging: WCF Channel Session Sample Demonstrates how to use Microsoft Azure Service Bus using Windows Communication Foundation (WCF) channels. The sample shows the use of WCF channels to send and receive messages via a Service Bus queue. The sample shows both session and non-session communication over the Service Bus. 1.8 Microsoft Azure Service Bus; Service Bus for Windows Server
Brokered Messaging: Transactions Demonstrates how to use the Microsoft Azure Service Bus messaging features within a transaction scope in order to ensure batches of messaging operations are committed atomically. 1.8 Microsoft Azure Service Bus; Service Bus for Windows Server
Brokered Messaging: Management Operations Using REST Demonstrates how to perform management operations on Service Bus using REST. 1.8 Microsoft Azure Service Bus; Service Bus for Windows Server
Resource Provider REST APIs Demonstrates how to use the new Service Bus RDFE REST APIs to manage namespaces and messaging entities. 1.8 Microsoft Azure Service Bus; Service Bus for Windows Server
Brokered Messaging: WCF Service Session Sample Demonstrates how to use Microsoft Azure Service Bus using the WCF service model. The sample shows the use of the WCF service model to accomplish session-based communication via a Service Bus queue. 1.8 Microsoft Azure Service Bus; Service Bus for Windows Server
Brokered Messaging: Request Response Demonstrates how to use the Microsoft Azure Service Bus and the request/response functionality. The sample shows simple clients and servers communicating via a Service Bus queue. 1.8 Microsoft Azure Service Bus; Service Bus for Windows Server
Brokered Messaging: Dead Letter Queue Demonstrates how to use Microsoft Azure Service Bus and the messaging "dead letter queue" functionality. The sample shows a simple sender and receiver communicating via a Service Bus queue. 1.8 Microsoft Azure Service Bus; Service Bus for Windows Server
Brokered Messaging: Deferred Messages Demonstrates how to use the message deferral feature of Microsoft Azure Service Bus. The sample shows a simple sender and receiver communicating via a Service Bus queue. 1.8 Microsoft Azure Service Bus; Service Bus for Windows Server
Brokered Messaging: Session Messages Demonstrates how to use Microsoft Azure Service Bus and the Messaging Session functionality. The sample shows simple senders and receivers communicating via a Service Bus queue. 1.8 Microsoft Azure Service Bus; Service Bus for Windows Server
Brokered Messaging: Request Response Topic Demonstrates how to implement the request/response pattern using Microsoft Azure Service Bus topics and subscriptions. The sample shows simple clients and servers communicating via a Service Bus topic. 1.8 Microsoft Azure Service Bus; Service Bus for Windows Server
Brokered Messaging: Request Response Queue Demonstrates how to use Microsoft Azure Service Bus and the request/response functionality. The sample shows simple clients and servers communicating via two Service Bus queues. 1.8 Microsoft Azure Service Bus; Service Bus for Windows Server
Brokered Messaging: Duplicate Detection Demonstrates how to use Microsoft Azure Service Bus duplicate message detection with queues. It creates two queues, one with duplicate detection enabled and other one without duplicate detection. 1.8 Microsoft Azure Service Bus; Service Bus for Windows Server
Brokered Messaging: Async Messaging Demonstrates how to use Microsoft Azure Service Bus to send and receive messages asynchronously from a queue. The queue provides decoupled, asynchronous communication between a sender and any number of receivers (here, a single receiver). 1.8 Microsoft Azure Service Bus; Service Bus for Windows Server
Brokered Messaging: Advanced Filters Demonstrates how to use Microsoft Azure Service Bus publish/subscribe advanced filters. It creates a topic and 3 subscriptions with different filter definitions, sends messages to the topic, and receives all messages from subscriptions. 1.8 Microsoft Azure Service Bus; Service Bus for Windows Server
Brokered Messaging: Messages Prefetch Demonstrates how to use the Microsoft Azure Service Bus messages prefetch feature. It demonstrates how to use the messages prefetch feature upon receive. 1.8 Microsoft Azure Service Bus; Service Bus for Windows Server

Service Bus reference tools

The following samples demonstrate various other features of the service.

Sample Name Description Minimum SDK Version Availability
Service Bus Explorer The Service Bus Explorer allows users to connect to a Service Bus service namespace and manage messaging entities in an easy manner. The tool provides advanced features such as import/export functionality, and the ability to test messaging entities and relay services. 1.8 Microsoft Azure Service Bus; Service Bus for Windows Server
Authorization: SBAzTool This sample demonstrates how to create and manage service identities in Microsoft Azure Active Directory Access Control (also known as Access Control Service or ACS) for use with Service Bus. N/A Microsoft Azure Service Bus

Next steps

See the following topics for conceptual overviews of Service Bus.