KafkaListner initialoffset消耗已确认的消息吗?

时间:2019-08-05 10:02:06

标签: spring spring-boot apache-kafka kafka-consumer-api

我在kafka中有465264条记录,但是我已经消耗了所有消息并且也确认了,但是当我尝试以初始偏移量开始消耗时,在确认后它再次消耗相同的消息。以下是我的代码:

@KafkaListener(
    id = "${kafka.buyers.product-sales-pricing.id}",
    groupId = "${kafka.buyers.group-id}",
    concurrency = "${kafka.buyers.concurrency}",
    topicPartitions = { @TopicPartition( topic = "${kafka.buyers.product-sales-pricing.topic}", partitionOffsets = @PartitionOffset( partition = "0", initialOffset = "465260" ) ) }
)
public void listen( List<String> messages, Acknowledgment ack ){}

Yml配置:

spring:
    kafka:
      bootstrapServers: kafka.moglilabs.com:29092
      consumer:
        enable-auto-commit: false
        autoOffsetReset: earliest
        keyDeserializer: org.apache.kafka.common.serialization.StringDeserializer
        valueDeserializer: org.apache.kafka.common.serialization.StringDeserializer #spring message converter will take care of deserialization
        max-poll-records: 1000

0 个答案:

没有答案