Giter Site home page Giter Site logo

nservicebussignalr's Introduction

NServiceBus and SignalR

Background

Having the distributed possibilities with NServiceBus in an event driven architecture and not taking it all the way to the client in a web application is just not good enough. We know that we can rely on NServiceBus for the messaging between servers and processes. SignalR is really an amazing candidate of enabling that next step. It is a bit rough but it is maturing every day and has an active community. I felt it was time to sort things out regarding NServiceBus and SignalR and how they interact. And to provide an example as well. I needed to do this for myself, but I hope that other people can find this useful as well.

Points of interest

This is a really simple sample and no detail has gone into any of the parts. The purpose to provide easy understanding of configuration of the two frameworks and the interactions between them.

Web Application

This is a ASP.NET MVC 4 Web Site from the basic template. The Web App has a simple page where three scenarios are demonstrated:

Hub

This is a standard Hub in SignalR. What I do in one browser gets sent to all the others (in this case). There's nothing special with this case.

Outside the Hub

This scenario is used when code outside of the Hub want to make use of the Hub connection and call methods on the client. This is our first step towards letting an NServiceBus handler calling clients.

NServiceBus handler using Hub

This scenario completes the circle. There are two ways to send messages. The first sends messages to the Console App where they are diplayed. The console app can also send messages to the client. It's like a chat. The second way is a loopback mechanism where the web sends a message to itself. This is in case you don't want to use the Console App at all.

Added packages:

  • NServiceBus 3.2.8
  • SignalR 0.5.3
  • jQuery 1.8.2

ConsoleApp

This is a very simple Console Application. The purpose is just to show that it is possible to send messages from a separate (server) process to the client (GUI even).

Added packages:

  • NServiceBus 3.2.8

Installation

You should be able to just fork the project and run the solution. But here are some things off the top of my head:

  • If you haven't run NServiceBus on the machine before, go to NServiceBus.com and download it and then run the 'runmefirst.bat' from the package. It will setup Message Queueing and the DTC and some other magical things. Don't forget to unblock the file before unzipping it.
  • The message queues are supposed to be created automatically, but NServiceBus might have a bad day (in terms of permissions) and fail to install them. The queues you need are (oh, and they are transactional):
    • NServiceBusSignalR.Web
    • NServiceBusSignalR.Web.Retries
    • NServiceBusSignalR.ConsoleApp
    • NServiceBusSignalR.ConsoleApp.Retries
    • NServiceBusSignalR.Error
  • You should run SignalR on an IIS or an IIS Express or a late version. Like 7.5.

Coming up

I want to add dependency injection to this as that is what I use myself and if I can isolate the interactions in a similar manner, I think I can learn some from that as well.

Questions, Thoughts?

Contact me on twitter @MikaelOstberg

nservicebussignalr's People

Contributors

mikeeast avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.