脉冲星管理
1. 脉冲星管理客户端
在Pulsar管理端,Spring Boot自动配置提供了脉冲星管理管理脉冲星星团。
管理层实现了一个名为脉冲星管理运营并提供一个createOrModify(创建或修改)方法通过合同处理主题管理。
当你使用脉冲星Spring Boot器时,你会获得脉冲星管理自动配置。
默认情况下,应用程序尝试连接到本地的 Pulsar 实例http://localhost:8080.
这可以通过设置Spring.pulsar.admin.service-url性质变为不同的取值,形式为(http|https)://<host>:<port>.
有许多应用程序属性可用于配置客户端。
参见spring.pulsar.admin.*应用属性。
1.1. 认证
访问需要认证的 Pulsar 集群时,管理客户端需要与普通 Pulsar 客户端相同的安全配置。
你可以通过替换来使用上述的安全配置spring.pulsar.client跟spring.pulsar.admin.
2. 自动主题创建
初始化时,脉冲星管理检查是否有脉冲星主题在应用语境中。
对于所有这样的Beans,脉冲星管理要么创建对应的主题,要么必要时修改划分的数量。
以下示例展示了如何加法脉冲星主题豆子让脉冲星管理自动为你创建主题:
@Bean
PulsarTopic simpleTopic(PulsarTopicBuilder topicBuilder) {
// This will create a non-partitioned persistent topic in the 'public/default' tenant/namespace
return topicBuilder.name("my-topic").build();
}
@Bean
PulsarTopic partitionedTopic(PulsarTopicBuilder topicBuilder) {
// This will create a persistent topic with 3 partitions in the provided tenant and namespace
return topicBuilder
.name("persistent://my-tenant/my-namespace/partitioned-topic")
.numberOfPartitions(3)
.build();
}
|
使用Spring靴时 |