Skip to content
davidfowl edited this page May 12, 2012 · 7 revisions

This article explains how to use the Windows Azure Service Bus backplane for SignalR. Introduced by Clemens Vasters on his blog and distributed via this NuGet package, this backplane uses the Windows Azure Service Bus as a messaging layer.

Setup

Install the SignalR libraries using NuGet:

Install-Package SignalR

Install the SignalR.WindowsAzureServiceBus package using NuGet:

Install-Package SignalR.WindowsAzureServiceBus

## Wiring Up the Windows Azure Service Bus Provider ## To wire up the service bus implementation, you'll need to add a little code to your App_Start or Global.asax.cs file, or by use of a custom IHttpModule. The use of a single extension method allows for the wire-up process, the signature of which is displayed below.
UseWindowsAzureServiceBus
(
   serviceBusNamespace, /* the service bus namespace prefix */
   serviceBusAccount,   /* "owner" or some other account */
   serviceBusAccountKey, /* the key, which can be copied from the Windows Azure portal */
   topicPathPrefix, /* the prefix applied to the name of each topic used */
   numberOfTopics /* how many topics across which messages will be sharded */
);
### Sample Global.asax.cs Usage ### ```csharp using System; using SignalR.WindowsAzureServiceBus;

namespace WindowsAzureServiceBusBackedSignalR { public class Global : System.Web.HttpApplication { private string serviceBusNamespace = "myazurenamespace"; private string serviceBusAccount = "owner"; private string serviceBusAccountKey = "fhsakjfdl22324323wehfjasdflkj2q22323ewykhwej2n33324na4sd=="; private string topicPathPrefix = "mywebapp"; private int numberOfTopics = 1;

    protected void Application_Start(object sender, EventArgs e)
    {
        SignalR.GlobalHost.DependencyResolver.UseWindowsAzureServiceBus(
            serviceBusNamespace, /* the service bus namespace prefix */
            serviceBusAccount,   /* "owner" or some other account */
            serviceBusAccountKey, /* the key, which can be copied from the Windows Azure portal */
            topicPathPrefix, /* the prefix applied to the name of each topic used */
            numberOfTopics /* how many topics across which messages will be sharded */
            );
    }

} }

Clone this wiki locally