private static async Task MainAsync(string[] args) { Console.WriteLine("Registering EventProcessor..."); //Event hub settings string EventHubName = Configuration["eventhub:eventHubName"]; string EventHubConnectionString = Configuration["eventhub:eventHubConnectionString"]; //Storage settings string StorageContainerName = Configuration["eventhub:storageContainerName"]; string StorageConnectionString = Configuration["eventhub:storageConnectionString"]; Console.WriteLine("Eventhub: " + EventHubName); Console.WriteLine("Storage container: " + StorageContainerName); //Setup event processor host var eventProcessorHost = new EventProcessorHost( EventHubName, PartitionReceiver.DefaultConsumerGroupName, EventHubConnectionString, StorageConnectionString, StorageContainerName); IDocumentService documentService = new DocumentService( Configuration["cosmosdb:endpoint"], Configuration["cosmosdb:key"], Configuration["cosmosdb:dbName"], Configuration["cosmosdb:collectionName"] ); IEventProcessorFactory processorFactory = new SimpleEventProcessorFactory(documentService); // Registers the Event Processor Host and starts receiving messages await eventProcessorHost.RegisterEventProcessorFactoryAsync(processorFactory); Console.WriteLine("Receiving. Press ENTER to stop worker."); Console.ReadLine(); // Disposes of the Event Processor Host await eventProcessorHost.UnregisterEventProcessorAsync(); }
private static async Task MainAsync(string[] args) { Console.WriteLine("Registering EventProcessor..."); //Event hub settings string EventHubName = Configuration["eventhub:eventHubName"]; string EventHubConnectionString = Configuration["eventhub:eventHubConnectionString"]; Console.WriteLine("Eventhub: " + EventHubName); Console.WriteLine("Eventhub connectionstring: " + EventHubConnectionString); //Storage settings string StorageContainerName = Configuration["eventhub:storageContainerName"]; string StorageConnectionString = Configuration["storage:storageConnectionString"]; Console.WriteLine("Storage container: " + StorageContainerName); Console.WriteLine("Storage connection string: " + StorageConnectionString); //Setup event processor host eventProcessorHost = new EventProcessorHost( EventHubName, PartitionReceiver.DefaultConsumerGroupName, EventHubConnectionString, StorageConnectionString, StorageContainerName); IDocumentService documentService = new DocumentService( Configuration["storage:storageConnectionString"], Configuration["storage:storageContainerName"] ); IEventProcessorFactory processorFactory = new SimpleEventProcessorFactory(documentService); // Registers the Event Processor Host and starts receiving messages await eventProcessorHost.RegisterEventProcessorFactoryAsync(processorFactory); }