static async Task MainAsync(string[] args) { try { config.Connectionstring(Environment.GetEnvironmentVariable("MessageHandler.EventHub.Connectionstring")); config.UseEventProcessingRuntime(); config.ChannelId("consoleEventHub"); config.DisruptorRingSize(1024); config.HandlerConfigurationId("test"); var leaseStore = new InMemoryLeaseStore <EventHubPump.CheckpointManagerLease>(new EventHubPump.CheckpointManagerLeaseCreator()); var leaseAllocation = new InMemoryLeaseAllocation <EventHubPump.CheckpointManagerLease>(leaseStore, new EventHubPump.CheckpointManagerLeaseCreator()); var pump = new EventHubPump(settings, leaseAllocation, leaseStore); config.RegisterMessagePump(pump); int invocationCount = 0; Func <IProcessingContext, Task> pipeline = async ctx => { await Console.Out.WriteLineAsync(invocationCount ++ + " " + DateTime.Now.ToLongTimeString()); Console.WriteLine(); }; config.Pipeline(pipeline); var runtime = await HandlerRuntime.Create(config); await runtime.Start(); await leaseAllocation.Allocate(); Console.WriteLine("Press a key to stop."); Console.ReadKey(); await runtime.Stop(); } catch (Exception e) { Console.WriteLine(e.Message); Console.ReadKey(); } }
static async Task MainAsync(string[] args) { try { config.Connectionstring(Environment.GetEnvironmentVariable("MessageHandler.AzureServiceBus.Connectionstring")); config.ChannelId("consoleTopic"); config.DisruptorRingSize(1024); config.HandlerConfigurationId("consoleSubscription"); var pump = new SubscriptionPump(settings); var messageReceiverSettings = new MessageReceiverSettings() { NumberOfReceivers = 20, BatchSize = 1000, ServerWaitTime = TimeSpan.FromMilliseconds(100) }; config.MessageReceiverSettings(messageReceiverSettings); config.RegisterMessagePump(pump); config.UseEventProcessingRuntime(); int invocationCount = 0; Func <IProcessingContext, Task> pipeline = async ctx => { await Console.Out.WriteLineAsync(invocationCount ++ + " " + DateTime.Now.ToLongTimeString()); }; config.Pipeline(pipeline); var runtime = await HandlerRuntime.Create(config); await runtime.Start(); Console.WriteLine("Press a key to stop."); Console.ReadKey(); await runtime.Stop(); } catch (Exception e) { Console.WriteLine(e.Message); Console.ReadKey(); } }