Commit e12eef45 authored by zhouxu's avatar zhouxu

增加自述文件

parent 9cf52d9f
### 通过 SmartLifecycle 自定义两个生命周期 (getPhase数值小的先加载)
1. 读取ons配置文件,根据配置启动消息队列生产者
2. 根据业务启动消费者
3. 发送同步活异步消息
* 使用方式
1. pom中增加依赖
```
<dependency>
<groupId>com.miya.huihua</groupId>
<artifactId>microservice-base</artifactId>
<version>版本号</version>
</dependency>
```
#### 增加生产者
```
@Service public class TestProductImpl implements TestProduct {
@Autowired(required = false)
private AliProducer aliProducer; @Override
public void sendMsg() {
User user = new User("你是谁", "100");
aliProducer.putEvent("MiyaHhsaasStatisticDev", user, "*");
}
}
```
#### 增加消费者
```
/**
* @author zhouxu
* @createTime 2020/01/19
* 继承 AliConsumer getTopic:指定订阅的topic getTags:指定订阅的tag */ @Component @Slf4j public class TestConsumerLister extends AliConsumer {
@Override
public String getTopic() {
return "MiyaHhsaasStatisticDev";
}
@Override
public List<String> getTags() {
return ImmutableList.of("*");
}
@Override
public void consumerMessage(String tag, String message) {
log.info("收到了新的消息tag为:{} ,message为:", tag, message);
}
}
```
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment