public Task OnMessage(Message message)
 {
     try
     {
         if (_messageQueueWorker.Submit(message))
         {
             _logger.LogDebug("Group [{0}]: Will commit at offset {1}", _consumerSettings.GetGroup(), message.TopicPartitionOffset);
             return(Commit(message.TopicPartitionOffset));
         }
     }
     catch (Exception e)
     {
         _logger.LogError(e, "Group [{0}]: Error occured while consuming a message: {0}, of type {1}", _consumerSettings.GetGroup(), message.TopicPartitionOffset, _consumerSettings.MessageType);
         throw;
     }
     return(Task.CompletedTask);
 }
Пример #2
0
        public KafkaConsumerProcessor(ConsumerSettings consumerSettings, TopicPartition topicPartition, IKafkaCommitController commitController, MessageBusBase messageBus, MessageQueueWorker <Message> messageQueueWorker)
        {
            Log.InfoFormat(CultureInfo.InvariantCulture, "Creating for Group: {0}, Topic: {1}, Partition: {2}, MessageType: {3}", consumerSettings.GetGroup(), consumerSettings.Topic, topicPartition, consumerSettings.MessageType);

            _messageBus         = messageBus;
            _consumerSettings   = consumerSettings;
            TopicPartition      = topicPartition;
            _commitController   = commitController;
            _messageQueueWorker = messageQueueWorker;
        }
Пример #3
0
 public GroupTopicConsumer(EventHubMessageBus messageBus, ConsumerSettings consumerSettings)
     : this(messageBus, new TopicGroup(consumerSettings.Topic, consumerSettings.GetGroup()), () => new PartitionConsumerForConsumers(messageBus, consumerSettings))
 {
 }
Пример #4
0
 public async ValueTask OnMessage([NotNull] ConsumeResult message)
 {
     try
     {
         if (_messageQueueWorker.Submit(message))
         {
             _logger.LogDebug("Group [{group}]: Will commit at offset {offset}", _consumerSettings.GetGroup(), message.TopicPartitionOffset);
             await Commit().ConfigureAwait(false);
         }
     }
     catch (Exception e)
     {
         _logger.LogError(e, "Group [{group}]: Error occured while consuming a message at offset: {offset}, of type {messageType}", _consumerSettings.GetGroup(), message.TopicPartitionOffset, _consumerSettings.MessageType);
         throw;
     }
 }
Пример #5
0
        public KafkaConsumerProcessor(ConsumerSettings consumerSettings, TopicPartition topicPartition, IKafkaCommitController commitController, MessageBusBase messageBus, MessageQueueWorker <ConsumeResult> messageQueueWorker)
        {
            _messageBus = messageBus ?? throw new ArgumentNullException(nameof(messageBus));

            _logger = _messageBus.LoggerFactory.CreateLogger <KafkaConsumerProcessor>();
            _logger.LogInformation("Creating for Group: {0}, Topic: {1}, Partition: {2}, MessageType: {3}", consumerSettings.GetGroup(), consumerSettings.Topic, topicPartition, consumerSettings.MessageType);

            _consumerSettings   = consumerSettings;
            TopicPartition      = topicPartition;
            _commitController   = commitController;
            _messageQueueWorker = messageQueueWorker;
        }