什么是新的?
2.0 自 1.2 以来的新增功能
本节介绍从 1.2 版到 2.0 版所做的更改。
Spring Retry 替换为 Core Retry
Spring Retry 的所有用法都已被 Spring Framework 最近引入的更简单的重试机制所取代。
这主要是重新启动消息容器时使用的内部实现细节。
这只会影响您提供自定义RetryTemplate
通过PulsarContainerFactoryCustomizer
豆。
这RetryTemplate
类仍然存在于 Core Retry 中,但包名称已从org.springframework.retry.support
自org.springframework.core.retry
并且 API 略有变化。
有关更多详细信息,请参阅提交。
清除
以下以前已弃用的 API 在 2.0.x 版中标记为删除,现已删除:
-
org.springframework.pulsar.config.ConcurrentPulsarListenerContainerFactory#setConcurrency
-
org.springframework.pulsar.config.ConcurrentPulsarListenerContainerFactoryCustomizer
-
org.springframework.pulsar.config.ListenerContainerFactory#createListenerContainer
-
org.springframework.pulsar.config.ReaderContainerFactory#createReaderContainer
-
org.springframework.pulsar.config.ProducerBuilderConfigurationUtil
-
org.springframework.pulsar.config.PulsarClientProxy#getPartitionsForTopic
-
org.springframework.pulsar.config.PulsarTopic#builder
-
org.springframework.pulsar.config.PulsarTopic#getFullyQualifiedTopicName
-
org.springframework.pulsar.config.Resolved#get
-
org.springframework.pulsar.test.support.model.UserPojo
-
org.springframework.pulsar.test.support.model.UserRecord
1.2 自 1.1 以来的新增功能
本节介绍从 1.1 版到 1.2 版所做的更改。
自定义对象映射器
您可以提供自己的JacksonObjectMapper
Pulsar 在生成和使用 JSON 消息时将使用。
有关更多详细信息,请参阅自定义对象映射器。
默认租户和命名空间
您可以指定在针对非完全限定主题 URL 生成或使用消息时使用的默认租户和/或命名空间。 有关更多详细信息,请参阅默认租户/命名空间。
消息容器启动策略
现在,您可以将消息侦听器容器启动失败策略配置为stop
,continue
或retry
.
有关更多详细信息,请参阅受支持的容器之一的相应部分@PulsarListener、@PulsarReader 或 @ReactivePulsarListener
消息容器工厂定制器(Spring Boot)
Spring Boot 引入了通用消息容器工厂定制器org.springframework.boot.pulsar.autoconfigure.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,它配置了域、租户和命名空间的默认值。
因此,如果您使用的是 Spring Boot,则只需在需要的地方注入构建器即可。
否则,请使用PulsarTopicBuilder
构造函数直接。
侦听器/读取器容器工厂
这PulsarContainerFactory
引入了通用接口来弥合侦听器和读取器容器工厂之间的差距。
作为其中的一部分,以下 API 已被弃用、复制和重命名:
-
ListenerContainerFactory#createListenerContainer
替换为ListenerContainerFactory#createRegisteredContainer
-
ReaderContainerFactory#createReaderContainer(E endpoint)
替换为ReaderContainerFactory#createRegisteredContainer
-
ReaderContainerFactory#createReaderContainer(String… topics)
替换为ReaderContainerFactory#createContainer
ConcurrentPulsarListenerContainerFactory定制器
目的ConcurrentPulsarListenerContainerFactoryCustomizer
是自定义 Spring Boot 自动配置的消息容器工厂。
但是,Spring Boot 引入了一个通用消息容器工厂定制器org.springframework.boot.pulsar.autoconfigure.PulsarContainerFactoryCustomizer<T extends PulsarContainerFactory<?, ?>>
这消除了对此定制器的需求。
替换 的所有实例ConcurrentPulsarListenerContainerFactoryCustomizer
跟org.springframework.boot.pulsar.autoconfigure.PulsarContainerFactoryCustomizer<ConcurrentPulsarListenerContainerFactoryCustomizer<?>>
.
清除
以下以前已弃用的侦听器终结点适配器已被删除,以支持侦听器终结点接口中的默认方法:
-
org.springframework.pulsar.config.PulsarListenerEndpointAdapter
-
org.springframework.pulsar.reactive.config.ReactivePulsarListenerEndpointAdapter
1.1 自 1.0 以来的新增功能
本节介绍从 1.0 版到 1.1 版所做的更改。
自动架构支持
如果没有机会提前知道 Pulsar 主题的模式,您可以使用 AUTO Schemas 生成/使用与代理之间的通用记录。 有关更多详细信息,请参阅使用 AUTO_SCHEMA 生产和使用 AUTO_SCHEMA 使用。
虽然上述链接侧重于PulsarTemplate 和@PulsarListener ,此功能也支持ReactivePulsarTemplate ,@ReactivePulsarListener 和@PulsarReader .
每个的详细信息都可以在本参考指南的相应部分中找到。 |
删除已选中的异常
框架提供的 API 不再抛出已检查的PulsarClientException
,而是不受检查的PulsarException
.
如果您之前接球或重新投掷PulsarClientException 只是为了安抚编译器并且实际上没有处理异常,您可以简单地删除catch 或throws 第。
如果您实际处理异常,则需要将PulsarClientException 跟PulsarException 在您的 catch 子句中。 |
测试支持
这spring-pulsar-test
模块现在可用于帮助测试 Spring for Apache Pulsar 应用程序。
有关更多详细信息,请参阅测试应用程序。