I have a custom NServiceBus feature implementation which is using feature startup task.
Here is the Setup method of the feature
protected override void Setup(FeatureConfigurationContext context)
{
context.Container.ConfigureComponent<GridFsDataBus>(DependencyLifecycle.SingleInstance);
context.Container.ConfigureComponent<GridFsDataBusCleaner>(DependencyLifecycle.InstancePerCall);
context.RegisterStartupTask(() => new MongoDbDataBusCleaner());
}
I cannot find a way to access any registered components(not only registered by mine) from within the task itself since the signature of task registration in NServiceBus 6 has changed and is forcing you to instantiate the instance of the task yourself.
Here is snippet of the task
class MongoDbDataBusCleaner : FeatureStartupTask, IDisposable
{
static readonly ILog Logger = LogManager.GetLogger(typeof(MongoDbDataBusCleaner));
public IMongoDatabase Database { get; set; }
public GridFsDataBusCleaner DataBusCleaner { get; set; }
public ReadOnlySettings Settings { get; set; }
protected override Task OnStart(IMessageSession session)
{
// all the class properties are null
// how to get components registered in container
The only thing that i can get to while in OnStart method is IMessageSession which lacks any container access.
The default property injection does not work since i had to instantiate the start up task on my own
Any help would be appreciated !