为什么我的消费者每次都会从主题中读取所有消息,即使auto.offset.reset = max?

时间:2017-07-07 06:23:46

标签: apache-kafka offset kafka-consumer-api

我已经在topic1上向Kafka发了5条消息并成功使用了它们。当我发送第6条消息并尝试消费时,我再次收到所有6条消息,而不是最新的(第6条)消息。

请注意我正在运行消费者命令行,而不是数据库连接器(访问模块)。连接器的配置属性auto.offset.reset设置为"最大"。(请参阅下面的日志中的所有配置属性)

另请参阅下面的OffsetChecker输出:

bin/kafka-run-class.sh kafka.tools.ConsumerOffsetChecker \
    --group testjob --zookeeper localhost:2181 --topic topic1

[2017-07-06 21:57:46,707] WARN WARNING: ConsumerOffsetChecker is deprecated and will be dropped in releases following 0.9.0. Use ConsumerGroupCommand instead. (kafka.tools.ConsumerOffsetChecker$)
Exiting due to: org.apache.zookeeper.KeeperException$NoNodeException: KeeperErrorCode = NoNode for /consumers/testjob/offsets/topic1/0.

有谁能告诉我问题出在哪里?

以下是显示配置属性的日志:

***Global config Properties***
*             client.id = rdkafka
*             message.max.bytes = 1200
*             receive.message.max.bytes = 100000000
*             metadata.request.timeout.ms = 60000
*             topic.metadata.refresh.interval.ms = 600000
*             topic.metadata.refresh.fast.cnt = 10
*             topic.metadata.refresh.fast.interval.ms = 250
*             topic.metadata.refresh.sparse = false
*             socket.timeout.ms = 60000
*             socket.send.buffer.bytes = 0
*             socket.receive.buffer.bytes = 0
*             socket.keepalive.enable = false
*             socket.max.fails = 3
*             broker.address.ttl = 300000
*             broker.address.family = any
*             statistics.interval.ms = 0
*             log_cb = 0x7fecb80c6dd0
*             log_level = 6
*             socket_cb = 0x7fecb80cd2f0
*             open_cb = 0x7fecb80ddd30
*             opaque = 0x2641280
*             internal.termination.signal = 0
*             queued.min.messages = 100000
*             queued.max.messages.kbytes = 1000000
*             fetch.wait.max.ms = 100
*             fetch.message.max.bytes = 1049776
*             fetch.min.bytes = 1
*             fetch.error.backoff.ms = 500
*             group.id = testjob
*             queue.buffering.max.messages = 100000
*             queue.buffering.max.ms = 1000
*             message.send.max.retries = 2
*             retry.backoff.ms = 100
*             compression.codec = none
*             batch.num.messages = 1000
*             delivery.report.only.error = false
*             request.required.acks = 1
*             enforce.isr.cnt = 0
*             request.timeout.ms = 5000
*             message.timeout.ms = 300000
*             produce.offset.report = false
*             auto.commit.enable = true
*             auto.commit.interval.ms = 60000
*             auto.offset.reset = largest    <<<<--------
*             offset.store.path = .
*             offset.store.sync.interval.ms = 0
*             offset.store.method = file
*             consume.callback.max.messages = 0

1 个答案:

答案 0 :(得分:0)

添加此属性 AUTO_OFFSET_RESET_CONFIG =&#34;最早&#34;它会起作用