Question

My team is running an environment with load balanced IIS web servers and MongoDB. We want to use SignalR to push notifications to our users (and possibly more in the future). I'm trying to implement a new SignalR ScaleoutMessageBus so that we can use our existing MongoDB as a backplane for SignalR. I found an implementation on GitHub that looks like it is the type of thing I want. Unfortunately, it was implemented for SignalR 0.5.3 and is quite incompatible with SignalR 2.0.2.

I'm trying to update it to get it working and have the following parts working:

  • Dependency injection properly loads the new message bus
  • Correctly connect to the database and follow the trailing cursor for new messages (not SignalR related)
  • Topics and subscriptions appear to work using existing functionality

I am having trouble understanding how some parts of the ScaleOutMessageBus work, particularly the function of message streams and how they relate to the overall functionality. Looking at the SQL backplane, it looks like I want to replace reading and writing to and from the streams with reading and writing to and from my database? Is that correct?

Here is my Send implementation (which seems to be working)

protected override Task Send(IList<Message> messages)
{
    MongoMessageWrapper mw = new MongoMessageWrapper(messages);

    if (ConnectionReady)
    {
        return Task.Factory.StartNew(() => _mongoCollection.Insert(mw)).Catch();
    }
    return OpenConnection().Then(() => Task.Factory.StartNew(() => _mongoCollection.Insert(mw)));
}

My MongoMessageWrapperClass extends ScaleoutMessage but ads an _id property that the trailing cursor references.

This appears to be correctly writing the messages to the database. I think that my next step is to create a new OnReceived that is called when my trailing cursor finds a new message and unwraps the data from Mongo to get the original message(s) and pass them on to the existing ScaleoutMessageBus base class.

If I do this, what should I pass in as the streamIndex and id values for OnReceived? Also the messages that I am receiving in my Send function are of type Message rather than ScaleoutMessage that OnReceived takes as a parameter. Should I just convert the IList to a ScaleoutMessage?

I haven't been able to find any documentation on building custom scaleout solutions and backplanes. Is there any available (other than wading through the source code to figure it out?

Was it helpful?

Solution

I came across an article of how to implement a ScaleoutMessageBus for NServiceBus. One of your questions where how to handle Message vs ScaleoutMessage it seems you can simply construct a ScaleoutMessage by passing in a Message to the constructor. I do know this is not a complete answer but maybe it can help the next person that finds this question on SO.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top