public KafkaMessageReceiver(ReceiveEndpointContext context, IConsumerLockContext <TKey, TValue> lockContext, IHeadersDeserializer headersDeserializer)
 {
     _context             = context;
     _lockContext         = lockContext;
     _headersDeserializer = headersDeserializer;
     _dispatcher          = context.CreateReceivePipeDispatcher();
 }
Esempio n. 2
0
 public ConsumerContextSupervisor(IClientContextSupervisor clientContextSupervisor, ReceiveSettings receiveSettings,
                                  IHostConfiguration hostConfiguration, IHeadersDeserializer headersDeserializer, Func <ConsumerBuilder <TKey, TValue> > consumerBuilderFactory)
     : base(new ConsumerContextFactory <TKey, TValue>(clientContextSupervisor, receiveSettings, hostConfiguration, headersDeserializer,
                                                      consumerBuilderFactory))
 {
     clientContextSupervisor.AddConsumeAgent(this);
 }
 public KafkaConsumerSpecification(ConsumerConfig consumerConfig, string topicName, IHeadersDeserializer headersDeserializer,
                                   Action <IKafkaTopicReceiveEndpointConfigurator <TKey, TValue> > configure)
 {
     _consumerConfig      = consumerConfig;
     Name                 = topicName;
     _endpointObservers   = new ReceiveEndpointObservable();
     _headersDeserializer = headersDeserializer;
     _configure           = configure;
 }
 public ConsumerContextFactory(IClientContextSupervisor clientContextSupervisor, ReceiveSettings receiveSettings,
                               IHostConfiguration hostConfiguration, IHeadersDeserializer headersDeserializer, Func <ConsumerBuilder <TKey, TValue> > consumerBuilderFactory)
 {
     _clientContextSupervisor = clientContextSupervisor;
     _receiveSettings         = receiveSettings;
     _headersDeserializer     = headersDeserializer;
     _hostConfiguration       = hostConfiguration;
     _consumerBuilderFactory  = consumerBuilderFactory;
 }
 public KafkaReceiveEndpointBuilder(IBusInstance busInstance, IReceiveEndpointConfiguration configuration,
                                    IKafkaHostConfiguration hostConfiguration, ReceiveSettings receiveSettings, IHeadersDeserializer headersDeserializer,
                                    Func <ConsumerBuilder <TKey, TValue> > consumerBuilderFactory)
     : base(configuration)
 {
     _busInstance            = busInstance;
     _configuration          = configuration;
     _hostConfiguration      = hostConfiguration;
     _receiveSettings        = receiveSettings;
     _headersDeserializer    = headersDeserializer;
     _consumerBuilderFactory = consumerBuilderFactory;
 }
Esempio n. 6
0
 public KafkaConsumerSpecification(IKafkaHostConfiguration hostConfiguration, ConsumerConfig consumerConfig, string topicName,
     IHeadersDeserializer headersDeserializer,
     Action<IKafkaTopicReceiveEndpointConfigurator<TKey, TValue>> configure)
 {
     _hostConfiguration = hostConfiguration;
     _consumerConfig = consumerConfig;
     _topicName = topicName;
     _endpointObservers = new ReceiveEndpointObservable();
     _headersDeserializer = headersDeserializer;
     _configure = configure;
     EndpointName = $"{KafkaTopicAddress.PathPrefix}/{_topicName}";
 }
        public KafkaReceiveContext(ConsumeResult <TKey, TValue> result, ReceiveEndpointContext receiveEndpointContext,
                                   IConsumerLockContext <TKey, TValue> lockContext, IHeadersDeserializer headersDeserializer)
            : base(false, receiveEndpointContext)
        {
            _result              = result;
            _lockContext         = lockContext;
            _headersDeserializer = headersDeserializer;

            var consumeContext = new KafkaConsumeContext <TKey, TValue>(this, _result);

            AddOrUpdatePayload <ConsumeContext>(() => consumeContext, existing => consumeContext);
        }
Esempio n. 8
0
        public KafkaReceiveEndpointContext(IBusInstance busInstance, IReceiveEndpointConfiguration endpointConfiguration,
                                           IKafkaHostConfiguration hostConfiguration,
                                           ReceiveSettings receiveSettings,
                                           IHeadersDeserializer headersDeserializer,
                                           Func <ConsumerBuilder <TKey, TValue> > consumerBuilderFactory)
            : base(busInstance.HostConfiguration, endpointConfiguration)
        {
            _busInstance = busInstance;
            _settings    = receiveSettings;

            _consumerContext = new Recycle <IConsumerContextSupervisor <TKey, TValue> >(() =>
                                                                                        new ConsumerContextSupervisor <TKey, TValue>(hostConfiguration.ClientContextSupervisor, _settings, busInstance.HostConfiguration,
                                                                                                                                     headersDeserializer, consumerBuilderFactory));
        }
        public KafkaConsumerContext(IHostConfiguration hostConfiguration, ReceiveSettings receiveSettings, IHeadersDeserializer headersDeserializer,
                                    ConsumerBuilder <TKey, TValue> consumerBuilder, CancellationToken cancellationToken)
            : base(cancellationToken)
        {
            var lockContext = new ConsumerLockContext <TKey, TValue>(hostConfiguration, receiveSettings);

            _consumer = consumerBuilder
                        .SetPartitionsAssignedHandler(lockContext.OnAssigned)
                        .SetPartitionsRevokedHandler(lockContext.OnUnAssigned)
                        .SetErrorHandler(OnError)
                        .Build();
            ReceiveSettings     = receiveSettings;
            HeadersDeserializer = headersDeserializer;

            _lockContext = lockContext;
            _executor    = new ChannelExecutor(1);
        }
        public KafkaTopicReceiveEndpointConfiguration(IKafkaHostConfiguration hostConfiguration, ConsumerConfig consumerConfig, string topic,
                                                      IBusInstance busInstance, IReceiveEndpointConfiguration endpointConfiguration, IHeadersDeserializer headersDeserializer)
            : base(endpointConfiguration)
        {
            _hostConfiguration     = hostConfiguration;
            _busInstance           = busInstance;
            _endpointConfiguration = endpointConfiguration;
            _consumerConfig        = consumerConfig;
            Topic = topic;

            SetValueDeserializer(new MassTransitJsonDeserializer <TValue>());
            SetKeyDeserializer(new MassTransitJsonDeserializer <TKey>());
            SetHeadersDeserializer(headersDeserializer);

            CheckpointInterval     = TimeSpan.FromMinutes(1);
            CheckpointMessageCount = 5000;
            ConcurrencyLimit       = 1;

            _consumerConfigurator = new PipeConfigurator <ConsumerContext <TKey, TValue> >();
        }
Esempio n. 11
0
 public void SetHeadersDeserializer(IHeadersDeserializer deserializer)
 {
     _headersDeserializer = deserializer ?? throw new ArgumentNullException(nameof(deserializer));
 }