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:
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.
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:
- 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
- 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?