# spring-boot-pulsar-starter-client
**Repository Path**: callmee/spring-boot-pulsar-starter-client
## Basic Information
- **Project Name**: spring-boot-pulsar-starter-client
- **Description**: Spring Boot Pulsar Starter
- **Primary Language**: Unknown
- **License**: MIT
- **Default Branch**: master
- **Homepage**: None
- **GVP Project**: No
## Statistics
- **Stars**: 1
- **Forks**: 0
- **Created**: 2022-09-14
- **Last Updated**: 2024-06-30
## Categories & Tags
**Categories**: Uncategorized
**Tags**: SpringBoot, pulsar
## README
# Spring Boot Pulsar Starter
> - Override By [pulsar-java-spring-boot-starter](https://github.com/majusko/pulsar-java-spring-boot-starter)
> - Simple Starter In Spring Boot By Pulsar Client
# 1. install
> version example:
> {pulsar.version}-{java.version}-{starter.version}[-SNAPSHOT]
| pulsar.version | java.version | starter.version | status |
|----------------|--------------|-----------------|----------|
| 2.10.0 | 11 | 1 | ✅RELEASE |
## 1.1 Maven
```xml
club.callmee
spring-boot-pulsar-starter-client
${pulsar-starter-client.version}
```
# 2. Use
```properties
# enable pulsar client starter
pulsar.enable=true
```
## 2.1 Producer
```java
@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
## 2.2 Consumer
```java
@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