Matt Smith's Blog

Software Engineering related topics

Event Queue for FubuMVC.ServerSentEvents

| Comments

Out of the box the event queue in FubuMVC.ServerSentEvents just stores all events in memory while the web application is running. While this will work great for many people it does have it’s limitations, namely that it is a built in memory leak. It was originally designed with the idea that those who used the library would override the event queue with their own implementation. There are a couple of things you can do here, you can either persist the events to long term memory, or build in a mechanism to reduce the events in the queue, or whatever else you would like to do. (Sound like the Fubu way of doing things or what!)

When you implement your own queue you will need to implement both the IEventQueue and IEventQueueFactory interfaces. Then register them in your fubu service registry like so:

Fubu Service Registry
SetServiceIfNone<IEventQueueFactory<TOPIC>, YOUREVENTQUEUEFACTORY>();

You will need to do this for each of your topics for which you would like your event queue to be used.

How you implement your event queue is entirely up to you. The solution that I implemented was an in memory queue which would self reduce when the number of events surpassed some count.