Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Real time event feeds with NServiceBus and SignalR

Real time event feeds with NServiceBus and SignalR

In this session Mark Taling and I explain how we used NServiceBus and SignalR to publish real time events from a production monitor. After a short intro to NServiceBus and SignalR, we dive into some techniques for combining the two:

1) SignalR for relaying events from the back end to a wide range of clients
2) Using SignalR as a transport for NServiceBus
3) Using NServiceBus as a backplane for scaling out SignalR

Roy Cornelissen

March 18, 2013
Tweet

More Decks by Roy Cornelissen

Other Decks in Programming

Transcript

  1. NServiceBus A service bus is an architectural style for integration

    To simplify communication between services in a distributed system
  2. A .NET framework to help implement SOA with the Service

    Bus architectural style Abstracts away transport, threading, queues, transactions Focuses on implementing business logic Highly pluggable
  3. Two way, persistent connection, initiated by client W3C draft, worked

    on by IETF Support (partial) in some browsers
  4. Server side events “Pub/Sub” like protocol over http Also still

    a W3C draft One-way, client needs extra channel for send Proxies need to know about content-type:text/event-stream
  5. But I want it now! Veruca Salt Willy Wonka &

    The Chocolate Factory, 1971
  6. Other options client 2 server POST “message” client 1 Got

    msg? “message” long polling POST “message” Got msg? “message” client 2 server POST “message” client 1 GET /forever <script> display(“message”); </script> forever frame POST “message” <script> display(“message”); </script> <iframe src=“/forever”>
  7. SignalR’s layers of abstraction SignalR will abstract away the actual

    protocol used, and adds a couple of layers on top to make things even easier
  8. protocols persistent connection hub web sockets server events long polling

    forever frame • Unified programming model • Deals with connectivity issues (connection slow, reconnect, disconnects) • Available for multiple types of clients • Messaging bus • Utilizes Json.NET for serialization SignalR 1.0
  9. Client/server boundaries fade Hubs let you provide a semantic API

    between client and server SignalR creates a proxy between the two parties client (javascript) var chat = $.connection.chatHub; … chat.server.message(“hi!”); … chat.client.notify = function(text) { // do something with text } server class ChatHub: Hub { public void message(string text) { Clients.All.notify(text); } } proxy dynamic
  10. SignalR options JavaScript .NET Windows Phone Silverlight WinRT iOS Android

    ASP.NET OWIN Custom SQL Redis Service Bus clients hosts backplanes
  11. Gateway Monitor Service Gateway IIS AppFabric input queue input queue

    MonitorHub: Hub NServiceBus MessageForwarder: IHandleMessages<T> GlobalHost .ConnectionManager .GetHubContext<MonitorHub>();.
  12. An NServiceBus backplane Backplane Service SignalR IIS AppFabric input queue

    NServiceBusMessageBus: ScaleoutMessageBus NServiceBus Receiver: IHandleMessages<MessagesAvailable> Bus.Send<DistributeMessage>() MessageDispatcher: IHandleMessages<DistributeMessage> Bus.Publish<MessagesAvailable>() OnReceived(…);. input queue
  13. Reliability offered by NServiceBus What about scalability of the backplane

    service itself? SignalR backplane Considerations