-
Notifications
You must be signed in to change notification settings - Fork 0
Azure service bus
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.
### Service Bus Setup ###You'll need to create a Service Bus Namespace to be used by SignalR. First, create a namespace using the Windows Azure management portal.
Install the SignalR libraries using NuGet:
Install-Package SignalR
Install the SignalR.WindowsAzureServiceBus package using NuGet:
Install-Package SignalR.WindowsAzureServiceBus
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 */
);You'll find the correct value for the serviceBusNamespace field by selecting the correct namespace in the administration console.
Scroll down in the properties window to find the correct values for the serviceBusAccount and serviceBusAccountKey values. Find the "View" button and click it to see the account and key values.
When the dialog opens you'll see GUI elements that make copying the two values easy.
using System;
using SignalR.WindowsAzureServiceBus;
namespace WindowsAzureServiceBusBackedSignalR
{
public class Global : System.Web.HttpApplication
{
private string serviceBusNamespace = "SignalRDemoNamespace";
private string serviceBusAccount = "owner";
private string serviceBusAccountKey = "sFH3zkD3uaEu6hu83rt6tyXt7tUghj8kq5rmQ2+sddsdfzwVIKMaLUegc=";
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 */
);
}
}
}Note, this web site is an ASP.NET site that runs in an Azure web role. The Visual Studio 2010 project is visible below. Currently, the Service Bus backplane is only supported by sites which run as Web Roles. A later release will allow for non-Web Role sites so that typical sites can make use of Service Bus.
To increase the number of topics used by the Service Bus (and therefore increase throughput and performance), increase the numberOfTopics field.
private int numberOfTopics = 4;This will result in more topics being created in the Service Bus namespace.






