对于最新稳定版本,请使用spring-cloud-stream 5.0.1spring-doc.cadn.net.cn

Tombstone Records

在使用压缩主题时,一个值为null的记录(也称为墓碑记录)表示键的删除。 要接收此类消息,可以在Spring Cloud Stream函数中使用以下策略。spring-doc.cadn.net.cn

@Bean
public Function<Message<Person>, String> myFunction() {
    return value -> {
        Object v = value.getPayload();
        String className = v.getClass().getName();
        if (className.isEqualTo("org.springframework.kafka.support.KafkaNull")) {
            // this is a tombstone record
        }
        else {
            // continue with processing
        }
    };
}