static void LaunchQueueProcessor() { IServiceBusCommandQueueProcessorFactory factory = ConfigureForDequeue(); QueueClient client = new QueueClient(ServiceBusConnectionString, "myqueue"); _commandQueueProcessor = factory.Create <SimpleCommand>(client); }
private static IServiceBusCommandQueueProcessorFactory ConfigureForDequeue() { if (_dequeueServiceProvider == null) { IServiceCollection serviceCollection = new ServiceCollection(); CommandingDependencyResolverAdapter resolver = new CommandingDependencyResolverAdapter( (fromType, toInstance) => serviceCollection.AddSingleton(fromType, toInstance), (fromType, toType) => serviceCollection.AddTransient(fromType, toType), (resolveType) => _dispatchServiceProvider.GetService(resolveType)); ICommandRegistry commandRegistry = resolver.AddCommanding(); resolver.AddQueues().AddAzureServiceBus(); // register our command to dispatch to a servie bus queue commandRegistry.Register <SimpleCommandHandler>(); _dequeueServiceProvider = serviceCollection.BuildServiceProvider(); } IServiceBusCommandQueueProcessorFactory serviceBusCommandQueueProcessorFactory = _dispatchServiceProvider.GetService <IServiceBusCommandQueueProcessorFactory>(); return(serviceBusCommandQueueProcessorFactory); }