消费者相关配置类为  org.apache.kafka.clients.consumer.ConsumerConfig

具有以下配置参数

1. GROUP_ID_CONFIG = "group.id";

   消费者分组ID,分组内的消费者只能消费该消息一次,不同分组内的消费者可以重复消费该消息。简单讲就是一条消息会被发送到不同的分组,每个分组是否消费该消息不会互相影响,但是,分组内的消息只能被其中一个消费者消费一次。Kafka利用这个分组来实现单播和多播的功能。

2. MAX_POLL_RECORDS_CONFIG = "max.poll.records";
  消费者每次poll数据时的最大数量。

3. MAX_POLL_INTERVAL_MS_CONFIG = "max.poll.interval.ms";
The maximum delay between invocations of poll() when using consumer group management. This places an upper bound on the amount of time that the consumer can be idle before fetching more records. If poll() is not called before expiration of this timeout, then the consumer is considered failed and the group will rebalance in order to reassign the partitions to another member. ";

4. SESSION_TIMEOUT_MS_CONFIG = "session.timeout.ms"
会话响应的时间,超过这个时间kafka可以选择放弃消费或者消费下一条消息
"The timeout used to detect consumer failures when using Kafka's group management facility. The consumer sends periodic heartbeats to indicate its liveness to the broker. If no heartbeats are received by the broker before the expiration of this session timeout, then the broker will remove this consumer from the group and initiate a rebalance. Note that the value must be in the allowable range as configured in the broker configuration by <code>group.min.session.timeout.ms</code> and <code>group.max.session.timeout.ms</code>.";
The expected time between heartbeats to the consumer coordinator when using Kafka's group management facilities. Heartbeats are used to ensure that the consumer's session stays active and to facilitate rebalancing when new consumers join or leave the group. The value must be set lower than <code>session.timeout.ms</code>, but typically should be set no higher than 1/3 of that value. It can be adjusted even lower to control the expected time for normal rebalances.";

6. BOOTSTRAP_SERVERS_CONFIG = "bootstrap.servers";
broker 地址 "host1:port1,host2:port2",-->
7. CLIENT_DNS_LOOKUP_CONFIG = "client.dns.lookup";

8. ENABLE_AUTO_COMMIT_CONFIG = "enable.auto.commit";
  为true则自动提交偏移量

9. AUTO_COMMIT_INTERVAL_MS_CONFIG = "auto.commit.interval.ms";
自动提交偏移量周期

10. PARTITION_ASSIGNMENT_STRATEGY_CONFIG = "partition.assignment.strategy";
The class name of the partition assignment strategy that the client will use to distribute partition ownership amongst consumer instances when group management is used";

11. AUTO_OFFSET_RESET_CONFIG = "auto.offset.reset";
重置消费偏移量策略
当偏移量没有初始值时或者参数非法时,比如数据被删除时的重置策略。
earliest:其他:抛出异常

40. DEFAULT_ISOLATION_LEVEL;

相关文章:

  • 2021-08-27
  • 2021-11-16
  • 2021-12-12
  • 2021-11-18
  • 2021-05-04
  • 2021-10-25
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-11-23
  • 2022-12-23
  • 2021-11-18
相关资源
相似解决方案