org.springframework.cloud.stream.binder.kafka.properties.KafkaConsumerProperties.getStartOffset()方法的使用及代码示例

x33g5p2x  于2022-01-24 转载在 其他  
字(4.9k)|赞(0)|评价(0)|浏览(91)

本文整理了Java中org.springframework.cloud.stream.binder.kafka.properties.KafkaConsumerProperties.getStartOffset()方法的一些代码示例,展示了KafkaConsumerProperties.getStartOffset()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。KafkaConsumerProperties.getStartOffset()方法的具体详情如下:
包路径:org.springframework.cloud.stream.binder.kafka.properties.KafkaConsumerProperties
类名称:KafkaConsumerProperties
方法名:getStartOffset

KafkaConsumerProperties.getStartOffset介绍

暂无

代码示例

代码示例来源:origin: spring-cloud/spring-cloud-stream-binder-kafka

protected ConsumerFactory<?, ?> createKafkaConsumerFactory(boolean anonymous, String consumerGroup,
    ExtendedConsumerProperties<KafkaConsumerProperties> consumerProperties) {
  Map<String, Object> props = new HashMap<>();
  props.put(ConsumerConfig.KEY_DESERIALIZER_CLASS_CONFIG, ByteArrayDeserializer.class);
  props.put(ConsumerConfig.VALUE_DESERIALIZER_CLASS_CONFIG, ByteArrayDeserializer.class);
  props.put(ConsumerConfig.ENABLE_AUTO_COMMIT_CONFIG, false);
  props.put(ConsumerConfig.AUTO_COMMIT_INTERVAL_MS_CONFIG, 100);
  props.put(ConsumerConfig.AUTO_OFFSET_RESET_CONFIG, anonymous ? "latest" : "earliest");
  props.put(ConsumerConfig.GROUP_ID_CONFIG, consumerGroup);
  Map<String, Object> mergedConfig = this.configurationProperties.mergedConsumerConfiguration();
  if (!ObjectUtils.isEmpty(mergedConfig)) {
    props.putAll(mergedConfig);
  }
  if (ObjectUtils.isEmpty(props.get(ConsumerConfig.BOOTSTRAP_SERVERS_CONFIG))) {
    props.put(ConsumerConfig.BOOTSTRAP_SERVERS_CONFIG, this.configurationProperties.getKafkaConnectionString());
  }
  if (!ObjectUtils.isEmpty(consumerProperties.getExtension().getConfiguration())) {
    props.putAll(consumerProperties.getExtension().getConfiguration());
  }
  if (!ObjectUtils.isEmpty(consumerProperties.getExtension().getStartOffset())) {
    props.put(ConsumerConfig.AUTO_OFFSET_RESET_CONFIG,
        consumerProperties.getExtension().getStartOffset().name());
  }
  return new DefaultKafkaConsumerFactory<>(props);
}

代码示例来源:origin: org.springframework.cloud/spring-cloud-stream-binder-kafka

protected ConsumerFactory<?, ?> createKafkaConsumerFactory(boolean anonymous, String consumerGroup,
    ExtendedConsumerProperties<KafkaConsumerProperties> consumerProperties) {
  Map<String, Object> props = new HashMap<>();
  props.put(ConsumerConfig.KEY_DESERIALIZER_CLASS_CONFIG, ByteArrayDeserializer.class);
  props.put(ConsumerConfig.VALUE_DESERIALIZER_CLASS_CONFIG, ByteArrayDeserializer.class);
  props.put(ConsumerConfig.ENABLE_AUTO_COMMIT_CONFIG, false);
  props.put(ConsumerConfig.AUTO_COMMIT_INTERVAL_MS_CONFIG, 100);
  props.put(ConsumerConfig.AUTO_OFFSET_RESET_CONFIG, anonymous ? "latest" : "earliest");
  props.put(ConsumerConfig.GROUP_ID_CONFIG, consumerGroup);
  Map<String, Object> mergedConfig = this.configurationProperties.mergedConsumerConfiguration();
  if (!ObjectUtils.isEmpty(mergedConfig)) {
    props.putAll(mergedConfig);
  }
  if (ObjectUtils.isEmpty(props.get(ConsumerConfig.BOOTSTRAP_SERVERS_CONFIG))) {
    props.put(ConsumerConfig.BOOTSTRAP_SERVERS_CONFIG, this.configurationProperties.getKafkaConnectionString());
  }
  if (!ObjectUtils.isEmpty(consumerProperties.getExtension().getConfiguration())) {
    props.putAll(consumerProperties.getExtension().getConfiguration());
  }
  if (!ObjectUtils.isEmpty(consumerProperties.getExtension().getStartOffset())) {
    props.put(ConsumerConfig.AUTO_OFFSET_RESET_CONFIG,
        consumerProperties.getExtension().getStartOffset().name());
  }
  return new DefaultKafkaConsumerFactory<>(props);
}

代码示例来源:origin: org.springframework.cloud/spring-cloud-stream-binder-kafka11

private ConsumerFactory<?, ?> createKafkaConsumerFactory(boolean anonymous, String consumerGroup,
    ExtendedConsumerProperties<KafkaConsumerProperties> consumerProperties) {
  Map<String, Object> props = new HashMap<>();
  props.put(ConsumerConfig.KEY_DESERIALIZER_CLASS_CONFIG, ByteArrayDeserializer.class);
  props.put(ConsumerConfig.VALUE_DESERIALIZER_CLASS_CONFIG, ByteArrayDeserializer.class);
  props.put(ConsumerConfig.ENABLE_AUTO_COMMIT_CONFIG, false);
  props.put(ConsumerConfig.AUTO_COMMIT_INTERVAL_MS_CONFIG, 100);
  props.put(ConsumerConfig.AUTO_OFFSET_RESET_CONFIG, anonymous ? "latest" : "earliest");
  props.put(ConsumerConfig.GROUP_ID_CONFIG, consumerGroup);
  if (!ObjectUtils.isEmpty(configurationProperties.getConsumerConfiguration())) {
    props.putAll(configurationProperties.getConsumerConfiguration());
  }
  if (ObjectUtils.isEmpty(props.get(ConsumerConfig.BOOTSTRAP_SERVERS_CONFIG))) {
    props.put(ConsumerConfig.BOOTSTRAP_SERVERS_CONFIG, this.configurationProperties.getKafkaConnectionString());
  }
  if (!ObjectUtils.isEmpty(consumerProperties.getExtension().getConfiguration())) {
    props.putAll(consumerProperties.getExtension().getConfiguration());
  }
  if (!ObjectUtils.isEmpty(consumerProperties.getExtension().getStartOffset())) {
    props.put(ConsumerConfig.AUTO_OFFSET_RESET_CONFIG,
        consumerProperties.getExtension().getStartOffset().name());
  }
  return new DefaultKafkaConsumerFactory<>(props);
}

相关文章