该版本仍在开发中,尚未被视为稳定。对于最新稳定版本,请使用 spring-cloud-stream 5.0.0!spring-doc.cadn.net.cn

墓碑唱片

使用压缩主题时,记录具有值(也称为墓碑记录)表示键的删除。 要在春云流函数中接收此类消息,可以使用以下策略。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
        }
    };
}