有什么新鲜事?
1.2版本自1.1以来的新内容
本节涵盖了从1.1版本到1.2版本所做的更改。
自定义对象映射器
你可以自己提供Jackson对象映射器Pulsar 在生成和使用 JSON 消息时会使用该数据。
详情请参见自定义对象映射器。
默认租户与命名空间
你可以指定默认租户和/或命名空间,用于生成或使用针对非完全限定主题URL的消息。 详情请参见默认租户/命名空间。
消息容器启动策略
你现在可以配置消息监听器容器启动失败策略为停,继续或重试.
更多详情请参见支持的容器@PulsarListener、@PulsarReader或@ReactivePulsarListener的相应部分
Message Container 工厂定制器(Spring Boot)
Spring Boot 推出了通用的消息容器工厂定制器org.springframework.boot.autoconfigure.pulsar.PulsarContainerFactoryCustomizer<T extends PulsarContainerFactory<?, ?>>可以用来进一步配置一个或多个自动配置的容器工厂,这些工厂支持以下监听器注释:
-
为
@PulsarListenerregister one or more PulsarContainerFactoryCustomizer<ConcurrentPulsarListenerContainerFactory<?>> beans. -
为
@PulsarReader注册一个或多个 PulsarContainerFactoryCustomizer<DefaultPulsarReaderContainerFactory<?>> beans. -
为
@ReactivePulsarListenerregister one or more PulsarContainerFactoryCustomizer<DefaultReactivePulsarListenerContainerFactory<?>> 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.autoconfigure.pulsar.PulsarContainerFactoryCustomizer<T extends PulsarContainerFactory<?, ?>>这样就不需要这个定制器了。
替换所有的实例ConcurrentPulsarListenerContainerFactoryCustomizer跟org.springframework.boot.autoconfigure.pulsar.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应用。
详情请参见测试应用。