有什么新鲜事?
2.0版本自1.2版本以来的新内容
本节介绍了从1.2版本到2.0版本所做的更改。
春季重试被核心重试取代
Spring Retry 的所有使用方式已被 Spring Framework 最近引入的更简单的重试机制所取代。
这主要是重启消息容器时使用的内部实现细节。
这只会影响你提供定制服务重试模板通过a脉冲集装箱工厂定制器豆。
这重试模板类在Core Retry中仍然存在,但包名已从org.springframework.retry.support自org.springframework.core.retryAPI 也略有变化。
详情请参见提交。
清除
先前弃用的 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版本所做的更改。
自定义对象映射器
你可以自己提供Jackson对象映射器Pulsar 在生成和使用 JSON 消息时会使用该数据。
详情请参见自定义对象映射器。
默认租户与命名空间
你可以指定默认租户和/或命名空间,用于生成或使用针对非完全限定主题URL的消息。 详情请参见默认租户/命名空间。
消息容器启动策略
你现在可以配置消息监听器容器启动失败策略为停,继续或重试.
更多详情请参见支持容器@PulsarListener或@PulsarReader的相应部分。
Message Container 工厂定制器(Spring Boot)
Spring Boot 推出了通用的消息容器工厂定制器org.springframework.boot.pulsar.autoconfigure.PulsarContainerFactoryCustomizer<T extends PulsarContainerFactory<?, ?>>可以用来进一步配置一个或多个自动配置的容器工厂,这些工厂支持以下监听器注释:
-
为
@PulsarListenerregister one or more PulsarContainerFactoryCustomizer<ConcurrentPulsarListenerContainerFactory<?>> beans. -
为
@PulsarReader注册一个或多个 PulsarContainerFactoryCustomizer<DefaultPulsarReaderContainerFactory<?>> beans.
弃用
PulsarClient#getPartitionsForTopic(java.lang.String)
版本3.3.1Pulsar客户端弃用了getPartitionsForTopic(java.lang.String)支持的getPartitionsForTopic(java.lang.String, boolean metadataAutoCreationEnabled).
脉冲星话题#构建者
使用Spring靴时脉冲星主题构建器现在是一个注册的 BEAN,已配置为域、租户和命名空间的默认值。
因此,如果你用的是Spring Boot,可以直接在需要的地方注入建材。
否则,请使用以下一种脉冲星主题构建器直接制造者。
听者/读者容器工厂
这脉冲星集装箱工厂引入了通用接口,以弥合监听器和读者容器工厂之间的差距。
作为其中一部分,以下 API 被弃用、复制并重命名:
-
ListenerContainerFactory#createListenerContainer替换为ListenerContainerFactory#createRegisteredContainer -
ReaderContainerFactory#createReaderContainer(E 端点)替换为ReaderContainerFactory#createRegisteredContainer -
ReaderContainerFactory#createReaderContainer(String...话题)替换为ReaderContainerFactory#createContainer
ConcurrentPulsarListenerContainerFactoryCustomizer
目的ConcurrentPulsarListenerContainerFactoryCustomizer是用来定制 Spring Boot 自动配置的消息容器工厂。
不过,Spring Boot 推出了通用的消息容器工厂定制工具org.springframework.boot.pulsar.autoconfigure.PulsarContainerFactoryCustomizer<T extends PulsarContainerFactory<?, ?>>这样就不需要这个定制器了。
替换所有的实例ConcurrentPulsarListenerContainerFactoryCustomizer跟org.springframework.boot.pulsar.autoconfigure.PulsarContainerFactoryCustomizer<ConcurrentPulsarListenerContainerFactoryCustomizer<?>>.
1.1自1.0以来新增了什么
本节介绍了从1.0版本到1.1版本所做的更改。
自动模式支持
如果无法提前了解 Pulsar 主题的结构,你可以使用 AUTO 架构来生成/消耗通用记录,发送/接收经纪人。 详情请参见《与AUTO_SCHEMA生产》和《用AUTO_SCHEMA消费》。
虽然上述链接主要关注脉冲星模板和@PulsarListener,这一功能也支持在反应脉冲星模板,@ReactivePulsarListener和@PulsarReader.
每个版本的详细信息可见本参考指南的相应章节。 |
移除已勾选的异常
框架提供的API不再抛出已检查的PulsarClientException而是无限制的脉冲星例外.
如果你之前是在接球或重投PulsarClientException为了安抚编译器,而不是我们实际处理异常,你可以直接移除你的抓住或抛出第。
如果你实际上是在处理异常,那你需要更换PulsarClientException跟脉冲星例外在你的附加条款里。 |
测试支持
这Spring脉冲星测试该模块现已提供,可帮助测试您的Spring for Apache Pulsar应用。
详情请参见测试应用。