Future<RecordMetadata> future = producer.send(new ProducerRecord<>(topic, messageKey, messageStr));RecordMetadata recordMetadata = future.get();log.info("partition: {}", recordMetadata.partition());log.info("offset: {}", recordMetadata.offset());

BrokerNotAvailableError and NotLeaderForPartitionError during production or consumption.auto.leader.rebalance.enable = true is set for the Kafka cluster and a rebalance is performed automatically, or when brokers are manually added/removed and a rebalance is manually triggered:ack = all and min.insync.replicas > 1, the message will not be lost because it is acknowledged on both the leader partition and follower partition.ack = 1, messages within the replica.lag.time.max.ms period may not have been synchronized to the follower partition, potentially causing message loss.ack = all and min.insync.replicas > 1, the message will not be lost because it is acknowledged on both the leader partition and follower partition.ack = 1, the leader switch will automatically synchronize the offsets in the partition. Therefore, messages will not be lost.Feedback