新增功能
自 1.1 以来 1.2 中的新增功能
本节介绍从版本 1.1 到版本 1.2 所做的更改。
自定义对象映射器
您可以提供自己的 JacksonObjectMapperPulsar 将在生成和使用 JSON 消息时使用。
有关更多详细信息,请参阅 Custom Object Mapper 。
默认租户和命名空间
您可以指定在针对非完全限定主题 URL 生成或使用消息时要使用的默认租户和/或命名空间。 有关更多详细信息,请参阅 默认租户/命名空间 。
消息容器启动策略
您现在可以将消息侦听器容器启动失败策略配置为stop,continue或retry.
有关更多详细信息,请参阅受支持的容器之一 @PulsarListener、@PulsarReader 或 @ReactivePulsarListener 的相应部分
消息容器工厂定制器 (Spring Boot)
Spring Boot 引入了一个通用的消息容器工厂定制器org.springframework.boot.autoconfigure.pulsar.PulsarContainerFactoryCustomizer<T extends PulsarContainerFactory<?, ?>>这可用于进一步配置一个或多个支持以下侦听器注释的自动配置的容器工厂:
-
为
@PulsarListener注册一个或多个 PulsarContainerFactoryCustomizer<ConcurrentPulsarListenerContainerFactory<?>> bean。 -
为
@PulsarReader注册一个或多个 PulsarContainerFactoryCustomizer<DefaultPulsarReaderContainerFactory<?>> bean。 -
为
@ReactivePulsarListener注册一个或多个 PulsarContainerFactoryCustomizer<DefaultReactivePulsarListenerContainerFactory<?>> bean。
弃用
PulsarClient#getPartitionsForTopic(java.lang.String)
版本3.3.1的 Pulsar 客户端弃用了getPartitionsForTopic(java.lang.String)赞成getPartitionsForTopic(java.lang.String, boolean metadataAutoCreationEnabled).
PulsarTopic#构建器
使用 Spring Boot 时,PulsarTopicBuilder现在是已注册的 Bean,它配置了 domain、tenant 和 namespace 的默认值。
因此,如果您使用的是 Spring Boot,则只需在需要时注入构建器即可。
否则,请使用PulsarTopicBuilder构造函数。
侦听器/ReaderContainerFactory
这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
自 1.0 以来 1.1 中的新增功能
本节介绍从版本 1.0 到版本 1.1 所做的更改。
自动架构支持
如果无法提前知道某个 Pulsar 主题的 schema,你可以使用 AUTO Schemas 向 broker 生成/消费泛型记录。 有关更多详细信息,请参阅使用 AUTO_SCHEMA 生产和使用 AUTO_SCHEMA。
虽然上述链接侧重于PulsarTemplate和@PulsarListener,此功能在ReactivePulsarTemplate,@ReactivePulsarListener和@PulsarReader.
每个选项的详细信息可以在本参考指南的相应部分中找到。 |
通过消息注释的默认主题/架构
您现在可以使用@PulsarMessage以指定在生成/使用该类型的消息时要使用的 default topic 和/或 default schema。
删除选中的异常
框架提供的 API 不再抛出 checkedPulsarClientException,而是未选中的PulsarException.
如果您之前正在接球或重新抛出PulsarClientException只是为了安抚编译器而不是实际处理异常,你可以简单地删除你的catch或throws第。
如果您实际上是在处理异常,则需要将PulsarClientException跟PulsarException在 catch 子句中。 |
测试支持
这spring-pulsar-test模块现在可用于帮助测试 Spring for Apache Pulsar 应用程序。
有关更多详细信息,请参阅测试应用程序。