public Task <ITriggerBinding> TryCreateAsync(TriggerBindingProviderContext context) { if (context == null) { throw new ArgumentNullException(nameof(context)); } ParameterInfo parameter = context.Parameter; EventHubTriggerAttribute attribute = parameter.GetCustomAttribute <EventHubTriggerAttribute>(inherit: false); if (attribute == null) { return(Task.FromResult <ITriggerBinding>(null)); } Func <ListenerFactoryContext, bool, Task <IListener> > createListener = (factoryContext, singleDispatch) => { var options = _options.Value; if (singleDispatch && !options.IsSingleDispatchEnabled) { throw new NotSupportedException("Binding to individual events is not supported. Please use batch processing by binding to an array instead."); } var checkpointStore = new BlobsCheckpointStore( _clientFactory.GetCheckpointStoreClient(), options.EventProcessorOptions.RetryOptions.ToRetryPolicy(), factoryContext.Descriptor.Id, _logger); IListener listener = new EventHubListener( factoryContext.Descriptor.Id, factoryContext.Executor, _clientFactory.GetEventProcessorHost(attribute.EventHubName, attribute.Connection, attribute.ConsumerGroup), singleDispatch, _clientFactory.GetEventHubConsumerClient(attribute.EventHubName, attribute.Connection, attribute.ConsumerGroup), checkpointStore, options, _logger); return(Task.FromResult(listener)); }; #pragma warning disable 618 ITriggerBinding binding = BindingFactory.GetTriggerBinding(new EventHubTriggerBindingStrategy(), parameter, _converterManager, createListener); #pragma warning restore 618 return(Task.FromResult(binding)); }
public Task <ITriggerBinding> TryCreateAsync(TriggerBindingProviderContext context) { if (context == null) { throw new ArgumentNullException(nameof(context)); } ParameterInfo parameter = context.Parameter; EventHubTriggerAttribute attribute = parameter.GetCustomAttribute <EventHubTriggerAttribute>(inherit: false); if (attribute == null) { return(Task.FromResult <ITriggerBinding>(null)); } Func <ListenerFactoryContext, bool, Task <IListener> > createListener = (factoryContext, singleDispatch) => { var options = _options.Value; var checkpointStore = new BlobCheckpointStoreInternal( _clientFactory.GetCheckpointStoreClient(), factoryContext.Descriptor.Id, _loggerFactory.CreateLogger <BlobCheckpointStoreInternal>()); IListener listener = new EventHubListener( factoryContext.Descriptor.Id, factoryContext.Executor, _clientFactory.GetEventProcessorHost(attribute.EventHubName, attribute.Connection, attribute.ConsumerGroup, singleDispatch), singleDispatch, _clientFactory.GetEventHubConsumerClient(attribute.EventHubName, attribute.Connection, attribute.ConsumerGroup), checkpointStore, options, _loggerFactory); return(Task.FromResult(listener)); }; #pragma warning disable 618 ITriggerBinding binding = BindingFactory.GetTriggerBinding(new EventHubTriggerBindingStrategy(), parameter, _converterManager, createListener); #pragma warning restore 618 ITriggerBinding eventHubTriggerBindingWrapper = new EventHubTriggerBindingWrapper(binding); return(Task.FromResult(eventHubTriggerBindingWrapper)); }