public GroupTopicConsumer(EventHubMessageBus messageBus, RequestResponseSettings requestResponseSettings) : this(messageBus, new TopicGroup(requestResponseSettings.Topic, requestResponseSettings.GetGroup()), () => new PartitionConsumerForResponses(messageBus, requestResponseSettings)) { }
public KafkaResponseProcessor(RequestResponseSettings requestResponseSettings, TopicPartition topicPartition, IKafkaCommitController commitController, MessageBusBase messageBus, ICheckpointTrigger checkpointTrigger) { _messageBus = messageBus ?? throw new ArgumentNullException(nameof(messageBus)); _requestResponseSettings = requestResponseSettings; TopicPartition = topicPartition; _commitController = commitController; _checkpointTrigger = checkpointTrigger; _logger = messageBus.LoggerFactory.CreateLogger <KafkaResponseProcessor>(); _logger.LogInformation("Creating for Group: {0}, Topic: {1}, Partition: {2}", requestResponseSettings.GetGroup(), requestResponseSettings.Topic, topicPartition); }
public async Task OnMessage(Message message) { try { await _messageBus.OnResponseArrived(message.Value, _requestResponseSettings.Topic).ConfigureAwait(false); } catch (Exception e) { if (_logger.IsEnabled(LogLevel.Error)) { _logger.LogError(e, "Error occured while consuming response message: {0}", new MessageContextInfo(_requestResponseSettings.GetGroup(), message)); } // For response messages we can only continue and process all messages in the lease // ToDo: Add support for retry ? if (_requestResponseSettings.OnResponseMessageFault != null) { // Call the hook _logger.LogTrace("Executing the attached hook from {0}", nameof(_requestResponseSettings.OnResponseMessageFault)); try { _requestResponseSettings.OnResponseMessageFault(_requestResponseSettings, message, e); } catch (Exception e2) { _logger.LogWarning(e2, "Error handling hook failed for message: {0}", new MessageContextInfo(_requestResponseSettings.GetGroup(), message)); } } } if (_checkpointTrigger.Increment()) { await _commitController.Commit(message.TopicPartitionOffset).ConfigureAwait(false); } }
public KafkaResponseProcessor(RequestResponseSettings requestResponseSettings, TopicPartition topicPartition, IKafkaCommitController commitController, MessageBusBase messageBus, ICheckpointTrigger checkpointTrigger) { Log.InfoFormat(CultureInfo.InvariantCulture, "Creating for Group: {0}, Topic: {1}, Partition: {2}", requestResponseSettings.GetGroup(), requestResponseSettings.Topic, topicPartition); _requestResponseSettings = requestResponseSettings; TopicPartition = topicPartition; _commitController = commitController; _messageBus = messageBus; _checkpointTrigger = checkpointTrigger; }