static void Main(string[] args) { var hubName = Configs.HUB_NAME; var iotHubConnctionString = Configs.IOT_HUB_ENDPOINT_CONNECTION_STRING; var storgaeConnectionString = Configs.STORAGE_CONNECTION_STRING; var storageContainerName = Configs.STORAGE_CONTAINER_NAME; var consumerGroupName = PartitionReceiver.DefaultConsumerGroupName; var processor = new EventProcessorHost( hubName, consumerGroupName, iotHubConnctionString, storgaeConnectionString, storageContainerName); processor.RegisterEventProcessorAsync <LoggingEventProcessor>().Wait(); var eventHubConfig = new EventHubConfiguration(); eventHubConfig.AddEventProcessorHost(hubName, processor); var configuration = new JobHostConfiguration(storgaeConnectionString); configuration.UseEventHub(eventHubConfig); Console.WriteLine("Starting job host (event processor)..."); var host = new JobHost(configuration); host.RunAndBlock(); }
public async Task ProcessEvents_Failure_Checkpoints() { var partitionContext = EventHubTests.GetPartitionContext(); var config = new EventHubConfiguration(); var checkpointer = new Mock <EventHubListener.ICheckpointer>(MockBehavior.Strict); checkpointer.Setup(p => p.CheckpointAsync(partitionContext)).Returns(Task.CompletedTask); List <EventData> events = new List <EventData>(); List <FunctionResult> results = new List <FunctionResult>(); for (int i = 0; i < 10; i++) { events.Add(new EventData(new byte[0])); var succeeded = i > 7 ? false : true; results.Add(new FunctionResult(succeeded)); } var executor = new Mock <ITriggeredFunctionExecutor>(MockBehavior.Strict); int execution = 0; executor.Setup(p => p.TryExecuteAsync(It.IsAny <TriggeredFunctionData>(), It.IsAny <CancellationToken>())).ReturnsAsync(() => { var result = results[execution++]; return(result); }); var loggerMock = new Mock <ILogger>(MockBehavior.Strict); var eventProcessor = new EventHubListener.EventProcessor(config, executor.Object, loggerMock.Object, true, checkpointer.Object); await eventProcessor.ProcessEventsAsync(partitionContext, events); checkpointer.Verify(p => p.CheckpointAsync(partitionContext), Times.Once); }
public EventHubIntegration(EventHubConfiguration configuration, EventHubOptions options) { Configuration = configuration; if (string.IsNullOrWhiteSpace(options.AccessKey)) { this.Client = new EventHubProducerClient(options.FullyQualifiedName, configuration.Name, new DefaultAzureCredential()); } else { this.Client = new EventHubProducerClient(options.ConnectionString, configuration.Name); } if (options.StorageOptions != default) { string consumerGroup = configuration.ConsumerGroup ?? "$Default"; var containerName = $"{configuration.Name.ToLower()}consumergroup"; BlobContainerClient = string.IsNullOrWhiteSpace(options.StorageOptions.AccountKey) ? new BlobContainerClient(new Uri(string.Format("https://{0}.blob.core.windows.net/{1}", options.StorageOptions.AccountName, containerName)), new DefaultAzureCredential()) : new BlobContainerClient(options.StorageOptions.GetConnectionString(), containerName); if (string.IsNullOrWhiteSpace(options.AccessKey)) { ClientReader = new EventProcessorClient(BlobContainerClient, consumerGroup, options.FullyQualifiedName, configuration.Name, new DefaultAzureCredential(), options.ProcessorOptions); } else { ClientReader = new EventProcessorClient(BlobContainerClient, consumerGroup, options.ConnectionString, configuration.Name, options.ProcessorOptions); } } }
public void EventHubBatchCheckpointFrequency(int num) { var config = new EventHubConfiguration(); config.BatchCheckpointFrequency = num; Assert.Equal(num, config.BatchCheckpointFrequency); }
public async Task ProcessEvents_MultipleDispatch_CheckpointsCorrectly(int batchCheckpointFrequency, int expected) { var partitionContext = EventHubTests.GetPartitionContext(); var config = new EventHubConfiguration { BatchCheckpointFrequency = batchCheckpointFrequency }; var checkpointer = new Mock <EventHubListener.ICheckpointer>(MockBehavior.Strict); checkpointer.Setup(p => p.CheckpointAsync(partitionContext)).Returns(Task.CompletedTask); var loggerMock = new Mock <ILogger>(MockBehavior.Strict); var executor = new Mock <ITriggeredFunctionExecutor>(MockBehavior.Strict); executor.Setup(p => p.TryExecuteAsync(It.IsAny <TriggeredFunctionData>(), It.IsAny <CancellationToken>())).ReturnsAsync(new FunctionResult(true)); var eventProcessor = new EventHubListener.EventProcessor(config, executor.Object, loggerMock.Object, false, checkpointer.Object); for (int i = 0; i < 100; i++) { List <EventData> events = new List <EventData>() { new EventData(new byte[0]), new EventData(new byte[0]), new EventData(new byte[0]) }; await eventProcessor.ProcessEventsAsync(partitionContext, events); } checkpointer.Verify(p => p.CheckpointAsync(partitionContext), Times.Exactly(expected)); }
public void InitializeFromHostMetadata() { var config = new EventHubConfiguration(); var context = new ExtensionConfigContext() { Config = new JobHostConfiguration() { #pragma warning disable CS0618 // Type or member is obsolete HostConfigMetadata = new JObject #pragma warning restore CS0618 // Type or member is obsolete { { "EventHub", new JObject { { "MaxBatchSize", 100 }, { "PrefetchCount", 200 }, { "BatchCheckpointFrequency", 5 } } } } } }; (config as IExtensionConfigProvider).Initialize(context); var options = config.GetOptions(); Assert.Equal(options.MaxBatchSize, 100); Assert.Equal(options.PrefetchCount, 200); Assert.Equal(config.BatchCheckpointFrequency, 5); }
public void InitializeFromHostMetadata() { var config = new EventHubConfiguration(); var context = new ExtensionConfigContext() { Config = new JobHostConfiguration() { #pragma warning disable CS0618 // Type or member is obsolete HostConfigMetadata = new JObject #pragma warning restore CS0618 // Type or member is obsolete { { "EventHub", new JObject { { "MaxBatchSize", 100 }, { "PrefetchCount", 200 }, { "BatchCheckpointFrequency", 5 }, } }, }, }, }; context.Config.AddService <ILoggerFactory>(new LoggerFactory()); (config as IExtensionConfigProvider).Initialize(context); var options = config.EventProcessorOptions; Assert.Equal(100, options.MaxBatchSize); Assert.Equal(200, options.PrefetchCount); Assert.Equal(5, config.BatchCheckpointFrequency); }
static void Main(string[] args) { var hubName = "iothub-ehub-ps-demo-hu-375407-6fb5327dad"; var iotHubConnectionString = "Endpoint=sb://ihsuprodblres002dednamespace.servicebus.windows.net/;SharedAccessKeyName=iothubowner;SharedAccessKey=9E1KqYZankE1dYx3oRW6V6ioUxeJgUrJ8uHrFD9fmTA="; var storageConnectionString = "DefaultEndpointsProtocol=https;AccountName=psdemostorage01;AccountKey=c94Pe+2fxXC0lWqiUeDa+RWrSWVGGlU2EAQzc0pBJViOjlwQiM1aU6qdzhU2MyMw9KDIq6JK6GWR1p3UqRQeGA==;EndpointSuffix=core.windows.net"; var storageContainerName = "message-processor-host"; var consumerGroupName = PartitionReceiver.DefaultConsumerGroupName; var processor = new EventProcessorHost( hubName, consumerGroupName, iotHubConnectionString, storageConnectionString, storageContainerName); processor.RegisterEventProcessorAsync <LoggingEventProcessor>().Wait(); var eventHubConfig = new EventHubConfiguration(); eventHubConfig.AddEventProcessorHost(hubName, processor); var configuration = new JobHostConfiguration(storageConnectionString); configuration.UseEventHub(eventHubConfig); Console.WriteLine("Starting job host…"); var host = new JobHost(configuration); host.RunAndBlock(); }
public void GetEventHubClient_AddsConnection(string expectedPathName, string connectionString) { EventHubConfiguration config = new EventHubConfiguration(); var client = config.GetEventHubClient("k1", connectionString); Assert.Equal(expectedPathName, client.Path); }
public TestFixture() { string connection = Environment.GetEnvironmentVariable("AzureWebJobsTestHubConnection"); Assert.True(!string.IsNullOrEmpty(connection), "Required test connection string is missing."); var host = new HostBuilder() .ConfigureDefaultTestHost <EventHubTestJobs>(b => { b.AddAzureStorage() .AddEventHubs(); }) .ConfigureServices(services => { services.AddSingleton <EventHubConfiguration>(serviceProvider => { var configuration = serviceProvider.GetRequiredService <IConfiguration>(); var eventHubConfig = new EventHubConfiguration(configuration); eventHubConfig.AddSender(TestHubName, connection); eventHubConfig.AddReceiver(TestHubName, connection); return(eventHubConfig); }); }) .Build(); Host = host.GetJobHost(); Host.StartAsync().GetAwaiter().GetResult(); }
public ReceiveTestWebJobs( string path, string connectionString, string storageConnectionString, int expected) { this._received = new int[expected]; this._expected = expected; JobHostConfiguration config = new JobHostConfiguration(); // Disable logging config.DashboardConnectionString = null; var eventHubConfig = new EventHubConfiguration(); eventHubConfig.AddReceiver(path, connectionString, storageConnectionString); config.UseEventHub(eventHubConfig); config.TypeLocator = new FakeTypeLocator(typeof(Program)); config.JobActivator = new JobActivator().Add(new Program(this)); var nm = new DictNameResolver(); nm.Add("eh", path); config.NameResolver = nm; //config.UseTimers(); _host = new JobHost(config); }
public void EntityPathInConnectionString(string expectedPathName, string connectionString) { EventHubConfiguration config = new EventHubConfiguration(); // Test sender config.AddSender("k1", connectionString); var client = config.GetEventHubClient("k1", null); Assert.Equal(expectedPathName, client.Path); }
/// <summary> /// Process a group of messages in a thread. /// </summary> /// <param name="configuration">Event Hub information</param> /// <param name="messages">List of messages to process</param> public static void ProcessMessages(EventHubConfiguration configuration, IEnumerable <ThroughputMessage> messages) { EventHubThreadData data = new EventHubThreadData() { Configuration = configuration, Messages = messages }; System.Threading.ThreadPool.QueueUserWorkItem(UploadMessages, data); }
/// <summary> /// Enable connecting to event hubs for sending and receiving events. This call is required to the <see cref="EventHubAttribute"/> /// and <see cref="EventHubTriggerAttribute"/> attributes on parameter bindings. /// </summary> /// <param name="config">job host configuration</param> public static void UseEventHub(this JobHostConfiguration config) { if (config == null) { throw new ArgumentNullException("config"); } var eventHubConfig = new EventHubConfiguration(); config.UseEventHub(eventHubConfig); }
public override void Initialize() { // Apply ServiceBus configuration ServiceBusConfiguration serviceBusConfig = new ServiceBusConfiguration(); JObject configSection = (JObject)Metadata.GetValue("serviceBus", StringComparison.OrdinalIgnoreCase); JToken value = null; if (configSection != null) { if (configSection.TryGetValue("maxConcurrentCalls", StringComparison.OrdinalIgnoreCase, out value)) { serviceBusConfig.MessageOptions.MaxConcurrentCalls = (int)value; } if (configSection.TryGetValue("autoRenewTimeout", StringComparison.OrdinalIgnoreCase, out value)) { serviceBusConfig.MessageOptions.AutoRenewTimeout = TimeSpan.Parse((string)value, CultureInfo.InvariantCulture); } if (configSection.TryGetValue("prefetchCount", StringComparison.OrdinalIgnoreCase, out value)) { serviceBusConfig.PrefetchCount = (int)value; } } EventProcessorOptions eventProcessorOptions = EventProcessorOptions.DefaultOptions; eventProcessorOptions.MaxBatchSize = 1000; int batchCheckpointFrequency = 1; configSection = (JObject)Metadata.GetValue("eventHub", StringComparison.OrdinalIgnoreCase); if (configSection != null) { if (configSection.TryGetValue("maxBatchSize", StringComparison.OrdinalIgnoreCase, out value)) { eventProcessorOptions.MaxBatchSize = (int)value; } if (configSection.TryGetValue("prefetchCount", StringComparison.OrdinalIgnoreCase, out value)) { eventProcessorOptions.PrefetchCount = (int)value; } if (configSection.TryGetValue("batchCheckpointFrequency", StringComparison.OrdinalIgnoreCase, out value)) { batchCheckpointFrequency = (int)value; } } _eventHubConfiguration = new EventHubConfiguration(eventProcessorOptions); _eventHubConfiguration.BatchCheckpointFrequency = batchCheckpointFrequency; Config.UseServiceBus(serviceBusConfig); Config.UseEventHub(_eventHubConfiguration); }
public void GivenConnectionStringNotInConfiguration_WhenAskingForValue_ThenItShouldThrow() { // arrange Environment.SetEnvironmentVariable(new EventHubConnectionStringKey(), null); Environment.GetEnvironmentVariables().Clear(); IEventHubConfiguration eventHubConfiguration = new EventHubConfiguration(); // act Action action = () => eventHubConfiguration.ConnectionString(); // assert action.Should().Throw <ConfigurationItemNotFoundException>(); }
public async Task CloseAsync_Shutdown_DoesNotCheckpoint() { var partitionContext = EventHubTests.GetPartitionContext(); var config = new EventHubConfiguration(); var checkpointer = new Mock <EventHubListener.ICheckpointer>(MockBehavior.Strict); var executor = new Mock <ITriggeredFunctionExecutor>(MockBehavior.Strict); var loggerMock = new Mock <ILogger>(MockBehavior.Strict); var eventProcessor = new EventHubListener.EventProcessor(config, executor.Object, loggerMock.Object, true, checkpointer.Object); await eventProcessor.CloseAsync(partitionContext, CloseReason.Shutdown); checkpointer.Verify(p => p.CheckpointAsync(partitionContext), Times.Never); }
public void Initialize_PerformsExpectedRegistrations() { JobHostConfiguration config = new JobHostConfiguration(); config.AddService <INameResolver>(new RandomNameResolver()); TestLoggerProvider loggerProvider = new TestLoggerProvider(); ILoggerFactory loggerFactory = new LoggerFactory(); loggerFactory.AddProvider(loggerProvider); config.LoggerFactory = loggerFactory; EventHubConfiguration eventHubConfiguration = new EventHubConfiguration(); IExtensionRegistry extensions = config.GetService <IExtensionRegistry>(); ITriggerBindingProvider[] triggerBindingProviders = extensions.GetExtensions <ITriggerBindingProvider>().ToArray(); Assert.Empty(triggerBindingProviders); IBindingProvider[] bindingProviders = extensions.GetExtensions <IBindingProvider>().ToArray(); Assert.Empty(bindingProviders); ExtensionConfigContext context = new ExtensionConfigContext { Config = config, }; ((IExtensionConfigProvider)eventHubConfiguration).Initialize(context); // ensure the EventHubTriggerAttributeBindingProvider was registered triggerBindingProviders = extensions.GetExtensions <ITriggerBindingProvider>().ToArray(); EventHubTriggerAttributeBindingProvider triggerBindingProvider = (EventHubTriggerAttributeBindingProvider)triggerBindingProviders.Single(); Assert.NotNull(triggerBindingProvider); // ensure the EventProcessorOptions ExceptionReceived event is wired up var eventProcessorOptions = eventHubConfiguration.EventProcessorOptions; var ex = new EventHubsException(false, "Kaboom!"); var ctor = typeof(ExceptionReceivedEventArgs).GetConstructors(BindingFlags.NonPublic | BindingFlags.Instance).Single(); var args = (ExceptionReceivedEventArgs)ctor.Invoke(new object[] { "TestHostName", "TestPartitionId", ex, "TestAction" }); var handler = (Action <ExceptionReceivedEventArgs>)eventProcessorOptions.GetType().GetField("exceptionHandler", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(eventProcessorOptions); handler.Method.Invoke(handler.Target, new object[] { args }); string expectedMessage = "EventProcessorHost error (Action=TestAction, HostName=TestHostName, PartitionId=TestPartitionId)"; var logMessage = loggerProvider.GetAllLogMessages().Single(); Assert.Equal(LogLevel.Error, logMessage.Level); Assert.Equal(expectedMessage, logMessage.FormattedMessage); Assert.Same(ex, logMessage.Exception); }
public void GivenConnectionStringInConfiguration_WhenAskingForValue_ThenItShouldReturnCorrectValue() { // arrange const string expected = "connection-string"; Environment.SetEnvironmentVariable(new EventHubConnectionStringKey(), expected); IEventHubConfiguration eventHubConfiguration = new EventHubConfiguration(); // act string actual = eventHubConfiguration.ConnectionString(); // assert actual.Should().Be(expected); }
public void LogExceptionReceivedEvent_NonMessagingException_LoggedAsError() { var ex = new MissingMethodException("What method??"); var ctor = typeof(ExceptionReceivedEventArgs).GetConstructors(BindingFlags.NonPublic | BindingFlags.Instance).Single(); var e = (ExceptionReceivedEventArgs)ctor.Invoke(new object[] { "TestHostName", "TestPartitionId", ex, "TestAction" }); EventHubConfiguration.LogExceptionReceivedEvent(e, _loggerFactory); string expectedMessage = "EventProcessorHost error (Action=TestAction, HostName=TestHostName, PartitionId=TestPartitionId)"; var logMessage = _loggerProvider.GetAllLogMessages().Single(); Assert.Equal(LogLevel.Error, logMessage.Level); Assert.Same(ex, logMessage.Exception); Assert.Equal(expectedMessage, logMessage.FormattedMessage); }
public static void UseEventHub(this JobHostConfiguration config, EventHubConfiguration eventHubConfig) { if (config == null) { throw new ArgumentNullException("config"); } if (eventHubConfig == null) { throw new ArgumentNullException("eventHubConfig"); } IExtensionRegistry extensions = config.GetService <IExtensionRegistry>(); extensions.RegisterExtension <IExtensionConfigProvider>(eventHubConfig); }
/// <summary> /// Process a single entry. Used mainly for recording messages to the event hub /// </summary> /// <param name="configuration">Event hub information</param> /// <param name="client">Application client name</param> /// <param name="state">State of the message</param> /// <param name="message">Content of the message</param> public static void ProcessOneOff(EventHubConfiguration configuration, String client, int state, String message) { ThroughputMessage oneOffMessage = new ThroughputMessage() { ClientId = client, Processed = DateTime.UtcNow, State = state, AILatency = 0, SendError = message }; EventHubUtility.ProcessMessages(configuration, new List <ThroughputMessage>() { oneOffMessage }); }
public void LogExceptionReceivedEvent_TransientEvent_LoggedAsVerbose() { var ex = new EventHubsException(true); Assert.True(ex.IsTransient); var ctor = typeof(ExceptionReceivedEventArgs).GetConstructors(BindingFlags.NonPublic | BindingFlags.Instance).Single(); var e = (ExceptionReceivedEventArgs)ctor.Invoke(new object[] { "TestHostName", "TestPartitionId", ex, "TestAction" }); EventHubConfiguration.LogExceptionReceivedEvent(e, _loggerFactory); string expectedMessage = "EventProcessorHost error (Action=TestAction, HostName=TestHostName, PartitionId=TestPartitionId)"; var logMessage = _loggerProvider.GetAllLogMessages().Single(); Assert.Equal(LogLevel.Debug, logMessage.Level); Assert.Same(ex, logMessage.Exception); Assert.Equal(expectedMessage, logMessage.FormattedMessage); }
// Please set the following connection strings in app.config for this WebJob to run: // AzureWebJobsDashboard and AzureWebJobsStorage static void Main() { var config = new JobHostConfiguration(); if (config.IsDevelopment) { string eventHubName = ConfigurationManager.AppSettings["EventHubName"]; string eventHubEndpoint = ConfigurationManager.AppSettings["EventHubEndpoint"]; config.UseDevelopmentSettings(); EventHubConfiguration hubConfig = new EventHubConfiguration(); hubConfig.AddReceiver(eventHubName, eventHubEndpoint); config.UseEventHub(hubConfig); } var host = new JobHost(config); // The following code ensures that the WebJob will be running continuously host.RunAndBlock(); }
private static void Main() { var eventHubConnectionString = ConfigurationManager.AppSettings["eventHubConnectionString"]; var eventHubName = ConfigurationManager.AppSettings["sourceEventHubName"]; var storageAccountName = ConfigurationManager.AppSettings["storageAccountName"]; var storageAccountKey = ConfigurationManager.AppSettings["storageAccountKey"]; var storageConnectionString = $"DefaultEndpointsProtocol=https;AccountName={storageAccountName};AccountKey={storageAccountKey}"; var eventProcessorHostName = Guid.NewGuid().ToString(); var eventProcessorHost = new EventProcessorHost(eventProcessorHostName, eventHubName, EventHubConsumerGroup.DefaultGroupName, eventHubConnectionString, storageConnectionString); var eventHubConfig = new EventHubConfiguration(); eventHubConfig.AddEventProcessorHost(eventHubName, eventProcessorHost); var config = new JobHostConfiguration(storageConnectionString); config.UseEventHub(eventHubConfig); Console.WriteLine("Registering EventProcessor..."); var options = new EventProcessorOptions(); options.ExceptionReceived += (sender, e) => { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine(e.Exception); Console.ResetColor(); }; eventProcessorHost.RegisterEventProcessorAsync <MessageProcessor>(options); var host = new JobHost(config); host.RunAndBlock(); eventProcessorHost.UnregisterEventProcessorAsync().Wait(); }
private static JobHostConfiguration Configure() { //TODO: Make all configuration work in the same way across Nether Console.WriteLine("Configuring WebJob (from Environment Variables"); s_webJobDashboardAndStorageConnectionString = ConfigResolver.Resolve("NETHER_WEBJOB_DASHBOARD_AND_STORAGE_CONNECTIONSTRING"); Console.WriteLine($"webJobDashboardAndStorageConnectionString:"); ConsoleEx.WriteConnectionString(s_webJobDashboardAndStorageConnectionString, 4); s_ingestEventHubConnectionString = ConfigResolver.Resolve("NETHER_INGEST_EVENTHUB_CONNECTIONSTRING"); Console.WriteLine($"ingestEventHubConnectionString:"); ConsoleEx.WriteConnectionString(s_ingestEventHubConnectionString, 4); s_ingestEventHubName = ConfigResolver.Resolve("NETHER_INGEST_EVENTHUB_NAME"); Console.WriteLine($"ingestEventHubName:"); Console.WriteLine($" {s_ingestEventHubName}"); s_analyticsStorageConnecitonString = ConfigResolver.Resolve("NETHER_ANALYTICS_STORAGE_CONNECTIONSTRING"); Console.WriteLine(); // Setup Web Job Config var jobHostConfig = new JobHostConfiguration(s_webJobDashboardAndStorageConnectionString) { NameResolver = new NameResolver(), StorageConnectionString = s_webJobDashboardAndStorageConnectionString }; var eventHubConfig = new EventHubConfiguration(); eventHubConfig.AddReceiver(s_ingestEventHubName, s_ingestEventHubConnectionString); jobHostConfig.UseEventHub(eventHubConfig); jobHostConfig.UseTimers(); if (jobHostConfig.IsDevelopment) { jobHostConfig.UseDevelopmentSettings(); } return(jobHostConfig); }
public override void Initialize() { // Apply ServiceBus configuration ServiceBusConfiguration serviceBusConfig = new ServiceBusConfiguration(); JObject configSection = (JObject)Metadata.GetValue("serviceBus", StringComparison.OrdinalIgnoreCase); JToken value = null; if (configSection != null) { if (configSection.TryGetValue("maxConcurrentCalls", StringComparison.OrdinalIgnoreCase, out value)) { serviceBusConfig.MessageOptions.MaxConcurrentCalls = (int)value; } if (configSection.TryGetValue("prefetchCount", StringComparison.OrdinalIgnoreCase, out value)) { serviceBusConfig.PrefetchCount = (int)value; } } EventProcessorOptions eventProcessorOptions = EventProcessorOptions.DefaultOptions; eventProcessorOptions.MaxBatchSize = 1000; configSection = (JObject)Metadata.GetValue("eventHub", StringComparison.OrdinalIgnoreCase); if (configSection != null) { if (configSection.TryGetValue("maxBatchSize", StringComparison.OrdinalIgnoreCase, out value)) { eventProcessorOptions.MaxBatchSize = (int)value; } if (configSection.TryGetValue("prefetchCount", StringComparison.OrdinalIgnoreCase, out value)) { eventProcessorOptions.PrefetchCount = (int)value; } } _eventHubConfiguration = new EventHubConfiguration(eventProcessorOptions); Config.UseServiceBus(serviceBusConfig); Config.UseEventHub(_eventHubConfiguration); }
static void Main(string[] args) { JobHostConfiguration config = new JobHostConfiguration(); config.Tracing.ConsoleLevel = System.Diagnostics.TraceLevel.Error; var eventHubConfig = new EventHubConfiguration(); eventHubConfig.AddReceiver(eventHubName, connectionString); config.UseEventHub(eventHubConfig); JobHost host = new JobHost(config); if (config.IsDevelopment) { config.UseDevelopmentSettings(); } //Send test messages Task.Run(() => { SendingRandomMessages(); }); host.RunAndBlock(); }
public EventHubEndToEndTests() { var config = new JobHostConfiguration() { TypeLocator = new FakeTypeLocator(typeof(EventHubTestJobs)) }; var eventHubConfig = new EventHubConfiguration(); string connection = Environment.GetEnvironmentVariable("AzureWebJobsTestHubConnection"); Assert.True(!string.IsNullOrEmpty(connection), "Required test connection string is missing."); eventHubConfig.AddSender(TestHubName, connection); eventHubConfig.AddReceiver(TestHubName, connection); connection = Environment.GetEnvironmentVariable(TestHub2Connection); Assert.True(!string.IsNullOrEmpty(connection), "Required test connection string is missing."); config.UseEventHub(eventHubConfig); _host = new JobHost(config); EventHubTestJobs.Result = null; }
public TestFixture() { var config = new JobHostConfiguration() { TypeLocator = new FakeTypeLocator(typeof(EventHubTestJobs)) }; var eventHubConfig = new EventHubConfiguration(); string connection = Environment.GetEnvironmentVariable("AzureWebJobsTestHubConnection"); Assert.True(!string.IsNullOrEmpty(connection), "Required test connection string is missing."); eventHubConfig.AddSender(TestHubName, connection); eventHubConfig.AddReceiver(TestHubName, connection); connection = Environment.GetEnvironmentVariable(TestHub2Connection); Assert.True(!string.IsNullOrEmpty(connection), "Required test connection string is missing."); config.UseEventHub(eventHubConfig); Host = new JobHost(config); Host.StartAsync().GetAwaiter().GetResult(); }