Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
M
microservice-base
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
zhouxu
microservice-base
Commits
e12eef45
Commit
e12eef45
authored
Jan 19, 2020
by
zhouxu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
增加自述文件
parent
9cf52d9f
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
51 additions
and
0 deletions
+51
-0
README.md
README.md
+51
-0
No files found.
README.md
0 → 100644
View file @
e12eef45
### 通过 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
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment