spring-kafka Acknowledgment 源码
spring-kafka Acknowledgment 代码
文件路径:/spring-kafka/src/main/java/org/springframework/kafka/support/Acknowledgment.java
/*
* Copyright 2015-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.kafka.support;
import java.time.Duration;
/**
* Handle for acknowledging the processing of a
* {@link org.apache.kafka.clients.consumer.ConsumerRecord}. Recipients can store the
* reference in asynchronous scenarios, but the internal state should be assumed transient
* (i.e. it cannot be serialized and deserialized later)
*
* @author Marius Bogoevici
* @author Gary Russell
*/
public interface Acknowledgment {
/**
* Invoked when the record or batch for which the acknowledgment has been created has
* been processed. Calling this method implies that all the previous messages in the
* partition have been processed already.
*/
void acknowledge();
/**
* Negatively acknowledge the current record - discard remaining records from the poll
* and re-seek all partitions so that this record will be redelivered after the sleep
* duration. Must be called on the consumer thread.
* <p>
* @param sleep the duration to sleep; the actual sleep time will be larger of this value
* and the container's {@code maxPollInterval}, which defaults to 5 seconds.
* @since 2.8.7
*/
default void nack(Duration sleep) {
throw new UnsupportedOperationException("nack(sleep) is not supported by this Acknowledgment");
}
/**
* Negatively acknowledge the record at an index in a batch - commit the offset(s) of
* records before the index and re-seek the partitions so that the record at the index
* and subsequent records will be redelivered after the sleep duration.
* Must be called on the consumer thread.
* <p>
* @param index the index of the failed record in the batch.
* @param sleep the duration to sleep; the actual sleep time will be larger of this value
* and the container's {@code maxPollInterval}, which defaults to 5 seconds.
* @since 2.8.7
*/
default void nack(int index, Duration sleep) {
throw new UnsupportedOperationException("nack(index, sleep) is not supported by this Acknowledgment");
}
}
相关信息
相关文章
spring-kafka AbstractKafkaHeaderMapper 源码
spring-kafka AllowDenyCollectionManager 源码
spring-kafka CompositeProducerInterceptor 源码
spring-kafka CompositeProducerListener 源码
spring-kafka DefaultKafkaHeaderMapper 源码
spring-kafka EndpointHandlerMethod 源码
spring-kafka ExponentialBackOffWithMaxRetries 源码
spring-kafka JacksonMimeTypeModule 源码
0
赞
热门推荐
-
2、 - 优质文章
-
3、 gate.io
-
8、 golang
-
9、 openharmony
-
10、 Vue中input框自动聚焦