Example #1
0
        public void Initialize(ExtensionConfigContext context)
        {
            if (context == null)
            {
                throw new ArgumentNullException(nameof(context));
            }

            _options.Value.ExceptionHandler = ExceptionReceivedHandler;
            _configuration.ConfigurationSection.Bind(_options);

            context
            .AddConverter <string, EventData>(ConvertStringToEventData)
            .AddConverter <EventData, string>(ConvertEventDataToString)
            .AddConverter <byte[], EventData>(ConvertBytes2EventData)
            .AddConverter <EventData, byte[]>(ConvertEventDataToBytes)
            .AddOpenConverter <OpenType.Poco, EventData>(ConvertPocoToEventData);

            // register our trigger binding provider
            var triggerBindingProvider = new EventHubTriggerAttributeBindingProvider(_converterManager, _options, _loggerFactory, _clientFactory);

            context.AddBindingRule <EventHubTriggerAttribute>()
            .BindToTrigger(triggerBindingProvider);

            // register our binding provider
            context.AddBindingRule <EventHubAttribute>()
            .BindToCollector(BuildFromAttribute);

            context.AddBindingRule <EventHubAttribute>()
            .BindToInput(attribute => _clientFactory.GetEventHubProducerClient(attribute.EventHubName, attribute.Connection));

            ExceptionHandler = (e =>
            {
                LogExceptionReceivedEvent(e, _loggerFactory);
            });
        }
        public void Initialize(ExtensionConfigContext context)
        {
            if (context == null)
            {
                throw new ArgumentNullException(nameof(context));
            }

            EventProcessorOptions options = _options.GetOptions();

            options.SetExceptionHandler(ExceptionReceivedHandler);

            // apply at config level (batchCheckpointFrequency)
            // TODO: Revisit this... All configurable options should move to a proper Options type.
            _configuration.ConfigurationSection.Bind(_options);

            context
            .AddConverter <string, EventData>(ConvertString2EventData)
            .AddConverter <EventData, string>(ConvertEventData2String)
            .AddConverter <byte[], EventData>(ConvertBytes2EventData)
            .AddConverter <EventData, byte[]>(ConvertEventData2Bytes)
            .AddOpenConverter <OpenType.Poco, EventData>(ConvertPocoToEventData);

            // register our trigger binding provider
            var triggerBindingProvider = new EventHubTriggerAttributeBindingProvider(_nameResolver, _converterManager, _options, _loggerFactory);

            context.AddBindingRule <EventHubTriggerAttribute>()
            .BindToTrigger(triggerBindingProvider);

            // register our binding provider
            context.AddBindingRule <EventHubAttribute>()
            .BindToCollector(BuildFromAttribute);

            ExceptionHandler = (e =>
            {
                LogExceptionReceivedEvent(e, _loggerFactory);
            });
        }