NServiceBus 5.2.24
We have a custom IConfigurationSource
that retrieves the endpoint mappings from the database:
public class CustomConfiguration : IConfigurationSource
{
public T GetConfiguration<T>() where T : class, new()
{
if (typeof(T) == typeof(UnicastBusConfig))
{
// Retrieve mappings from database
// ...
return new UnicastBusConfig { MessageEndpointMappings = mappings } as T;
}
return ConfigurationManager.GetSection(typeof(T).Name) as T;
}
}
But we’ve noticed that GetConfiguration()
gets called multiple times for type UnicastBusConfig
during the endpoint initialization, thus querying the database and reconstructing the object every time. If this cannot be avoided, is there a way to cache the mappings instead?