0

I'm trying to create a javascript event subscriber for NServicebus and I would like to know if my thoughts are valid and if there are any common pitfalls in this design.

I'm purposing the following components:

  1. ASP.NET MVC BusController (ASyncController)

    • receives subscriptions from the javascript clients and returns some sort of sessionId for the client to use in further communication.
    • async ActionMethod Receive which will return a json serialized EventMessage.
    • has a generic messagehandler, which will filter and queue up events for clients who subscribed for it.
  2. javascript client

    • can subscribe to 1 or more events using the subscribe action method of the BusController
    • can Receive events by long-polling the Receive method of the BusController with the received sessionId.

There are a few problems:

  1. How to detect when a client disconnects?
    • I've thought about a simple timout system, which tells the client to re-initiate the connection with the Receive Action Method
  2. I'm worried about the performance of a generic messagehandler in the buscontroller, handling all messages in my system. Has anyone else had experience with this?
Rik
  • 483
  • 3
  • 12

1 Answers1

0

You can always try something that work right out of the box. http://pservicebus.codeplex.com/

it comes with a javascript api that allows you to do pub-sub just like you would do it in .net code.

it is already coded to use Http Streaming/Comet as needed and switch to long polling when using browser that does not support it.

Here is a sample of using the javascript api pub-sub. http://pservicebus.codeplex.com/SourceControl/changeset/view/7169bd78a707#pServiceBus%201.0.2%2fSamples%2fJS%20API%20WebChat%2fScripts%2fchat.js

rpgmaker
  • 800
  • 1
  • 4
  • 7
  • Does it come with an NServicebus adapter? – Rik Aug 30 '11 at 11:47
  • No it does not, it has nothing to do with NServiceBus. If you want to place messages on MSMQ in the same format as expected in NServiceBus, then you can write your own Transport Adapter that does just that and include it in the ESB Transports folder so that message can be sent directly to MSMQ in the same format as expected in NServiceBus. But I don't see the need except you have your entire infrastructure already builted on top of NServiceBus; since It can write to not just MSMQ, it can write to many other protocols which you can then do the extra work of calling nservicebus stuff if needed – rpgmaker Aug 30 '11 at 12:38