代码拉取完成,页面将自动刷新
- Override By pulsar-java-spring-boot-starter
- Simple Starter In Spring Boot By Pulsar Client
version example:
{pulsar.version}-{java.version}-{starter.version}[-SNAPSHOT]
pulsar.version | java.version | starter.version | status |
---|---|---|---|
2.10.0 | 11 | 1 | ✅RELEASE |
<dependency>
<groupId>club.callmee</groupId>
<artifactId>spring-boot-pulsar-starter-client</artifactId>
<version>${pulsar-starter-client.version}</version>
</dependency>
# enable pulsar client starter
pulsar.enable=true
@Slf4j
@Service
public class TestProducer {
@PostConstruct
public void initDone(){
log.info("初始化生产者测试实例");
}
@PulsarProducer(topic = {TestTopicConfiguration.DEMO, TestTopicConfiguration.DEMO2, TestTopicConfiguration.DEMO3})
public String send(){
return "hello for String DEMO";
}
}
WARN
- must invoke method throw Spring IOC
- must have return type
@Slf4j
@Service
public class TestConsumer {
@PostConstruct
public void initDone() {
log.info("初始化消费者测试实例");
}
@PulsarConsumer(topic = TestTopicConfiguration.DEMO)
public void consume(String msg) {
System.out.println(msg);
}
@PulsarConsumer(topic = TestTopicConfiguration.DEMO2)
public void consume2(String msg) {
System.out.println(msg);
}
@PulsarConsumer(topic = TestTopicConfiguration.DEMO3,paramName = "msg1")
public void consume3(String msg, String msg1) {
System.out.println("msg: " + msg);
System.out.println("msg1: " + msg1);
}
}
WARN
- Supports specifying parameter names by annotation param named "paramName"
- but limited by JVM environment --parameter
- while multiple formal parameters in consumer method,and no specifying parameter in annotation define,there will be auto inject into all formal parameters which equal message types
- any formal parameters which did not match msg type in consumer method will assign into null value
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。