Skip to content

roycornelissen/SignalR.NServiceBus

Repository files navigation

SignalR.NServiceBus

NServiceBus backplane for SignalR

To use this backplane in a SignalR host, add a reference to SignalR.NServiceBus, initialize an IBus and configure SignalR to use NServiceBus. In ASP.NET, this would look something like this:

In Startup.cs:

	using Microsoft.AspNet.SignalR;
	using Microsoft.AspNet.SignalR.Messaging;
	using NServiceBus;
	using Owin;

	namespace DemoWebApp
	{
		public class Startup
		{
			public IBus Bus;

			public void Configuration(IAppBuilder app)
			{
				// Any connection or hub wire up and configuration should go here
				app.MapSignalR();

				Bus = Configure
					.With()
					.DefaultBuilder()
					.UseTransport<Msmq>()
					.UseInMemoryTimeoutPersister()
					.UnicastBus()
					.LoadMessageHandlers()
					.CreateBus()
					.Start();

				var config = new ScaleoutConfiguration() { MaxQueueLength = 100 }; // Or whatever you want
				GlobalHost.DependencyResolver.UseNServiceBus(Bus, config);
			}
		}
	}

The website in the demo project is mapped to local IIS. In order to make this work, you must make sure that the App Pool user has permission to access the queues involved in this sample: all queues starting with signalr.nservicebus.backplaneservice and all queues starting with system.web:

  • signalr.nservicebus.backplaneservice

  • signalr.nservicebus.backplaneservice.retries

  • signalr.nservicebus.backplaneservice.timeouts

  • signalr.nservicebus.backplaneservice.timeoutdispatcher

  • system.web

  • system.web.retries

  • system.web.timeouts

  • system.web.timeoutdispatcher

Also, make sure that you have configured the endpoint of the backplane in the config of your SignalR host:

    <configuration>
      <configSections>
        <section name="UnicastBusConfig" type="NServiceBus.Config.UnicastBusConfig, NServiceBus.Core" />
        <section name="MessageForwardingInCaseOfFaultConfig" type="NServiceBus.Config.MessageForwardingInCaseOfFaultConfig, NServiceBus.Core" />
      </configSections>
      <UnicastBusConfig>
        <MessageEndpointMappings>
          <!-- the endpoint on which the backplane is listening for commands -->
          <!-- SignalR will subscribe to new messages via that endpoint -->
          <add Messages="SignalR.NServiceBus" Endpoint="signalr.nservicebus.backplane" />
        </MessageEndpointMappings>
      </UnicastBusConfig>
    
      <MessageForwardingInCaseOfFaultConfig ErrorQueue="error" />
    </configuration>

To run the backplane itself, just start the SignalR.NServiceBus.BackplaneService project (it uses the NServiceBus generic host).

Author

Roy Cornelissen

For more info, see my blogpost

About

NServiceBus backplane for SignalR

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 3

  •  
  •  
  •