“墓碑”记录的空有效载荷与日志压缩

使用日志压缩时,你可以发送和接收消息用于识别密钥删除的有效载荷。 你也可以收到值是其他原因,比如可能返回的解串器当它无法反序列化某个值时。spring-doc.cadn.net.cn

生成零有效载荷

你可以发送一个值为反应脉冲星模板通过 a消息参数值为发送方法,例如:spring-doc.cadn.net.cn

reactiveTemplate
        .send(null, Schema.STRING)
        .subscribe();
发送空值时必须指定模式类型,因为系统无法从中确定消息的类型有效载荷。

消耗空有效载荷

@ReactivePularListener有效载荷根据其消息参数类型传递到监听器方法,具体如下:spring-doc.cadn.net.cn

参数类型 转账价值

原始spring-doc.cadn.net.cn

spring-doc.cadn.net.cn

用户自定义spring-doc.cadn.net.cn

spring-doc.cadn.net.cn

org.apache.pulsar.client.api.Message<T>spring-doc.cadn.net.cn

非零的脉冲星消息getValue()返回spring-doc.cadn.net.cn

org.springframework.messaging.Message<T>spring-doc.cadn.net.cn

非空 Spring 消息 其getPayload()返回脉冲星零spring-doc.cadn.net.cn

Flux<org.apache.pulsar.client.api.Message<T>>spring-doc.cadn.net.cn

非零通量,其条目为非零脉冲星消息,其getValue()返回spring-doc.cadn.net.cn

Flux<org.springframework.messaging.Message<T>>spring-doc.cadn.net.cn

非零通量,其条目为非空 Spring 消息,其getPayload()返回脉冲星零spring-doc.cadn.net.cn

当传入值为(即具有原始类型或用户定义类型的单记录监听器)你必须使用@Payload参数注释必要 = 错误.
使用Spring时org.springframework.messaging.Message对于你的监听器有效载荷类型,其通用类型信息必须足够宽泛以接受Message<PulsarNull>(例如:消息,留言<?>Message<Object>). 这是因为 Spring 消息不允许其有效载荷为空值,而是使用脉冲星零占 位 符。

如果是压缩日志的墓碑消息,通常还需要密钥,以便应用程序判断哪个密钥是”删除". 以下示例展示了这样的构型:spring-doc.cadn.net.cn

@ReactivePulsarListener(
        topics = "my-topic",
        subscriptionName = "my-topic-sub",
        schemaType = SchemaType.STRING)
Mono<Void> myListener(
        @Payload(required = false) String msg,
        @Header(PulsarHeaders.KEY) String key) {
    ...
}
使用流式消息监听器时 (通量) 头部支持有限,因此在对数压缩场景中作用较差。