什么是新内容?
最新更新 in 1.2 自 1.1
本部分涵盖从1.1版本到1.2版本的更改内容。
自定义对象映射器
You can provide your own Jackson ObjectMapper that Pulsar will use when producing and consuming JSON messages.
See Custom Object Mapper for more details.
默认租户和命名空间
您可以在使用非完全限定的主题URL进行消息的生产和消费时,指定默认租户和/或命名空间。 查看 默认租户 / 命名空间 以获取更多详情。
消息容器启动策略
You can now configure the message listener container startup failure policy to stop, continue, or retry.
For more details see the corresponding section for one of the supported containers @PulsarListener, @PulsarReader, or @ReactivePulsarListener
消息容器工厂自定义器 (Spring Boot)
Spring Boot 引入了一个通用的消息容器工厂自定义器 org.springframework.boot.autoconfigure.pulsar.PulsarContainerFactoryCustomizer<T extends PulsarContainerFactory<?, ?>>,可以用于进一步配置一个或多个为以下监听器注解所支持的自动配置容器工厂:
-
为 0 注册一个或多个 PulsarContainerFactoryCustomizer<ConcurrentPulsarListenerContainerFactory<?>> beans。
-
为 0 注册一个或多个 PulsarContainerFactoryCustomizer<DefaultPulsarReaderContainerFactory<?>> beans。
-
为 0 注册一个或多个 PulsarContainerFactoryCustomizer<DefaultReactivePulsarListenerContainerFactory<?>> beans。
弃用
PulsarClient#getPartitionsForTopic(java.lang.String)
版本 3.3.1 的 Pulsar 客户端弃用 getPartitionsForTopic(java.lang.String),改用 getPartitionsForTopic(java.lang.String, boolean metadataAutoCreationEnabled)。
Pulsar主题#构建器
当使用 Spring Boot 时,PulsarTopicBuilder 现在是一个已注册的 bean,其 domain、tenant 和 namespace 配置使用默认值。
因此,如果您使用 Spring Boot,可以在需要的地方直接注入 builder。
否则,请直接使用其中一个 PulsarTopicBuilder 构造函数。
监听器/读取器容器工厂
The PulsarContainerFactory 共用接口被引入,以在监听器和阅读器容器工厂之间建立桥梁。
作为这部分内容的一部分,以下API被弃用、复制并重命名:
-
ListenerContainerFactory#createListenerContainer替换为ListenerContainerFactory#createRegisteredContainer -
ReaderContainerFactory#createReaderContainer(E endpoint)替换为ReaderContainerFactory#createRegisteredContainer -
ReaderContainerFactory#createReaderContainer(String… topics)替换为ReaderContainerFactory#createContainer
ConcurrentPulsarListenerContainerFactoryCustomizer
ConcurrentPulsarListenerContainerFactoryCustomizer 的目的是自定义 Spring Boot 自动配置的消息容器工厂。
然而,Spring Boot 引入了一个通用的消息容器工厂自定义器 org.springframework.boot.autoconfigure.pulsar.PulsarContainerFactoryCustomizer<T extends PulsarContainerFactory<?, ?>>,从而不再需要此自定义器。
替换所有 ConcurrentPulsarListenerContainerFactoryCustomizer 实例为 org.springframework.boot.autoconfigure.pulsar.PulsarContainerFactoryCustomizer<ConcurrentPulsarListenerContainerFactoryCustomizer<?>>。
移除
以下此前已弃用的监听器端点适配器已移除,以便优先使用监听器端点接口中的默认方法:
-
org.springframework.pulsar.config.PulsarListenerEndpointAdapter -
org.springframework.pulsar.reactive.config.ReactivePulsarListenerEndpointAdapter
最新更新 in 1.1 自 1.0
本部分涵盖了从 1.0 版本到 1.1 版本的更改内容。
自动 Schema 支持
如果没有提前知道 Pulsar 主题的模式,您可以使用 AUTO Schemas 来向/从 brokers 生产/消费通用记录。 查看 使用 AUTO_SCHEMA 生产 和 使用 AUTO_SCHEMA 消费 以获取更多详情。
虽然上述链接重点介绍了 PulsarTemplate 和 @PulsarListener,但该功能也支持在 ReactivePulsarTemplate、@ReactivePulsarListener 和 @PulsarReader 中使用。每个版本的详细信息都可以在其参考指南的相应部分中找到。 |
移除受检异常
框架提供的API不再抛出受检的PulsarClientException,而是抛出不受检的PulsarException。
如果你之前只是捕获或重新抛出 PulsarClientException 来让编译器满意,但实际上并没有处理该异常,你可以简单地移除你的 catch 或 throws 子句。
如果你实际上是在处理该异常,你则需要在 catch 子句中将 PulsarClientException 替换为 PulsarException。 |
测试支持
The spring-pulsar-test 模块现已可用,以帮助您测试 Spring for Apache Pulsar 应用程序。
查看 测试应用程序 了解更多详情。