I have code like this.
var sampleBus = BusConfigurator.Instance
.ConfigureBus((cfg, host) =>
{
cfg.ReceiveEndpoint(host, "sampleQueue", e =>
{
e.UseScheduledRedelivery(r => r.Intervals(TimeSpan.FromMinutes(5));
e.UseMessageRetry(r => r.Interval(5, 5000));
e.Consumer<ConsumerClass1>();
});
});
sampleBus.Start();
I have a lot of consumer classes and i want to handle this with config file.How can i convert class names in config file to ConsumerClasses.
foreach(string className in consumerClassNameList){
????
var sampleBus = BusConfigurator.Instance
.ConfigureBus((cfg, host) =>
{
cfg.ReceiveEndpoint(host, "sampleQueue", e =>
{
e.UseScheduledRedelivery(r => r.Intervals(TimeSpan.FromMinutes(5));
e.UseMessageRetry(r => r.Interval(5, 5000));
e.Consumer<???>();
});
});
sampleBus.Start();
}
Each ConsumerClass derive from :
public class ConsumerClass1<T> : IConsumer<T> where T : class
Appraciate for any help.
EDIT
I asked question wrong.This code,
e.Consumer<ConsumerClass1>();
is not initialize a class.It is invoking a method.
public static void Consumer<TConsumer>(this IReceiveEndpointConfigurator configurator, Action<IConsumerConfigurator<TConsumer>> configure = null) where TConsumer : class, IConsumer, new();
Sorry for wrong question.Question should be "how to call method with generic type parameter dynamically". I found answer here.