Tag Archives: Tweak

Listener Performance Tweak

We have covered Listeners before (Extending MicroLite with custom Listeners) but it is worth mentioning that MicroLite uses them internally to manage object identifiers (for example using the IdentifierStrategy.Identity with MS SQL Server or IdentifierStrategy.AutoIncrement with SQLite).

There are a number of Listeners included in MicroLite and by default they are all loaded so that all functionality is implemented and the configuration is as simple as possible. It is easy however, to control which listeners are loaded. By doing so, you reduce the number of actions invoked in the session pipeline.

In your application startup (before calling Configure...) simply clear the listeners collection and add the listeners you want to run. This can be a combination of listeners provided by MicroLite and any custom listeners you wish to use.

using MicroLite.Listeners;

Listener.Listeners.Clear(); // Clear all default IListeners.
Listener.Listeners.Add<IdentityListener>(); // Just add the IListeners you use.
...

Configure.Extensions()...

Configure.Fluently()...

You can use this from MicroLite 1.2 onwards.

The list of MicroLite supplied Listeners is available here and will be maintained as other listeners are added.