The following code works fine except when hangfire enques it.
container.AddFacility<TypedFactoryFacility>()
.Register(
Classes.FromThisAssembly()
.BasedOn(typeof (ICommandHandler<>))
.WithServiceAllInterfaces()
.LifestyleTransient(),
Component.For<ICommandHandlerFactory>().AsFactory(),
Component.For<ICommandDispatcher>().ImplementedBy(typeof (CommandDispatcher)));
“No component for supporting the service CommandDispatcher was found”
public void Execute<TCommand>(TCommand command) where TCommand : ICommand
{
var handler = _commandHandlerFactory.Resolve<TCommand>();
handler.Handle(command);
}
public void ExecuteAsync<TCommand>(TCommand command) where TCommand : ICommand
{
BackgroundJob.Enqueue(
() => Execute(command));
}
The async method will not work as hangfire windsor is unable to retrieve my command dispatcher service?
JobActivator.Current = new WindsorJobActivator(_container.Kernel);
GlobalConfiguration.Configuration
.UseSqlServerStorage("");
app.UseHangfireDashboard();
app.UseHangfireServer();