[2025-05-27] 添加 engine-starter-rocketmq 使用说明
All checks were successful
Publish to Confluence / confluence (push) Successful in 1m0s

This commit is contained in:
liuxiaohua 2025-05-28 18:59:46 +08:00
parent 2ab1e991b4
commit eaea981ace
2 changed files with 802 additions and 0 deletions

View File

@ -0,0 +1,110 @@
<!-- Space: qifu -->
<!-- Parent: 后端技术&知识&规范 -->
<!-- Parent: 技术方案 -->
<!-- Parent: 基建 -->
<!-- Parent: 00-基础组件 -->
<!-- Parent: 00-EngineStarterFeign使用指南 -->
<!-- Title: 20250509-engine-starter-feign-2.0.0 -->
<!-- Macro: :anchor\((.*)\):
Template: ac:anchor
Anchor: ${1} -->
<!-- Macro: \!\[.*\]\((.+)\)\<\!\-\- width=(.*) \-\-\>
Template: ac:image
Url: ${1}
Width: ${2} -->
<!-- Macro: \<\!\-\- :toc: \-\-\>
Template: ac:toc
Printable: 'false'
MinLevel: 2
MaxLevel: 4 -->
<!-- Include: 杂项/声明文件.md -->
<!-- :toc: -->
# engine-starter-rocketmq 使用教程
> 这是一个基于 `rocketmq-spring-boot-starter` 的扩展项目
## 特性
- [X] `YmRocketMqClient` 消息发送工具类
## 快速开始
- **注意:** `qifu-saas-parent >= 2.0.0-SNAPSHOT`
### 添加依赖
```xml
<dependency>
<groupId>com.yuanmeng.engine</groupId>
<artifactId>engine-starter-rocketmq</artifactId>
<version>2.0.0-SNAPSHOT</version>
</dependency>
```
### 配置 RocketMQ
```yaml
rocketmq:
name-server: rocketmq.qifu.com:30938
producer:
group: qifu-saas-xxx
namespace: dev
# 发送消息超时时间默认3000
sendMessageTimeout: 10000
consumer:
group: qifu-saas-xxx
namespace: dev
# 一次拉取消息最大值,注意是拉取消息的最大值而非消费最大值
pull-batch-size: 10
```
### 创建需要的 Topic 和 ConsumerGroup
- Rocketmq 的 topic 和 consumer group 都需要手动创建
- 通过 RocketMQ 控制台创建
## 工具使用
### 发送消息
```java
@RestController
@RequestMapping("/demo")
public class DemoController {
@GetMapping("/send")
public String send() {
// 发送消息,会自动添加 SkyWalking 链路追踪信息
DemoMessage message = new DemoMessage()
SendResult result = YmRocketMqClient.sendSync("demo-topic", "demo-tag", message);
return "发送成功:" + result;
}
}
```
### 消费消息
```java
@Component
@RocketMQMessageListener(
topic = "demo-topic",
selectorExpression = "demo-tag",
consumerGroup = "${yuanmeng.rocketmq.consumer-group.demo:demo-consumer-group}"
)
public class DemoConsumer implements RocketMQListener<MessageExt> {
@Override
public void onMessage(MessageExt message) {
DemoMessage demoMessage = JSONObject.parseObject(message.getBody(), DemoMessage.class);
log.info("处理消费消息结果:{} tag = {} messageId = {}", demoMessage, message.getTags(), message.getMsgId());
// 处理业务逻辑...
}
}
```
## 完整配置
```yaml
yuanmeng:
rocketmq:
enable: true
```

View File

@ -0,0 +1,692 @@
{
"type": "excalidraw",
"version": 2,
"source": "https://excalidraw-jetbrains-plugin",
"elements": [
{
"id": "eEeoZS16uG56nDApOZs9N",
"type": "rectangle",
"x": 428,
"y": 182,
"width": 890,
"height": 531,
"angle": 0,
"strokeColor": "#1e1e1e",
"backgroundColor": "transparent",
"fillStyle": "solid",
"strokeWidth": 2,
"strokeStyle": "solid",
"roughness": 1,
"opacity": 100,
"groupIds": [],
"frameId": null,
"roundness": {
"type": 3
},
"seed": 237716243,
"version": 38,
"versionNonce": 1202678579,
"isDeleted": false,
"boundElements": null,
"updated": 1748332926954,
"link": null,
"locked": false
},
{
"id": "pf4yy9KXBQgwxA3C-PpKb",
"type": "rectangle",
"x": 460,
"y": 208,
"width": 209,
"height": 484,
"angle": 0,
"strokeColor": "#1e1e1e",
"backgroundColor": "transparent",
"fillStyle": "solid",
"strokeWidth": 2,
"strokeStyle": "solid",
"roughness": 1,
"opacity": 100,
"groupIds": [],
"frameId": null,
"roundness": {
"type": 3
},
"seed": 1067551955,
"version": 45,
"versionNonce": 1348156499,
"isDeleted": false,
"boundElements": null,
"updated": 1748332932619,
"link": null,
"locked": false
},
{
"id": "gnKMHC9g78htOUSF4simT",
"type": "text",
"x": 497,
"y": 234,
"width": 120,
"height": 25,
"angle": 0,
"strokeColor": "#1e1e1e",
"backgroundColor": "transparent",
"fillStyle": "solid",
"strokeWidth": 2,
"strokeStyle": "solid",
"roughness": 1,
"opacity": 100,
"groupIds": [],
"frameId": null,
"roundness": null,
"seed": 553007603,
"version": 61,
"versionNonce": 672080371,
"isDeleted": false,
"boundElements": null,
"updated": 1748332947819,
"link": null,
"locked": false,
"text": "应用服务列表",
"fontSize": 20,
"fontFamily": 1,
"textAlign": "left",
"verticalAlign": "top",
"baseline": 18,
"containerId": null,
"originalText": "应用服务列表",
"lineHeight": 1.25
},
{
"id": "szCTcE7b6MjJ_VJoOtK5e",
"type": "rectangle",
"x": 703,
"y": 212,
"width": 594,
"height": 201,
"angle": 0,
"strokeColor": "#1e1e1e",
"backgroundColor": "transparent",
"fillStyle": "solid",
"strokeWidth": 2,
"strokeStyle": "solid",
"roughness": 1,
"opacity": 100,
"groupIds": [],
"frameId": null,
"roundness": {
"type": 3
},
"seed": 1066369331,
"version": 88,
"versionNonce": 1619923069,
"isDeleted": false,
"boundElements": null,
"updated": 1748332995352,
"link": null,
"locked": false
},
{
"id": "oHMTtBDiLbGIa3p40GqC2",
"type": "text",
"x": 918,
"y": 228,
"width": 120,
"height": 25,
"angle": 0,
"strokeColor": "#1e1e1e",
"backgroundColor": "transparent",
"fillStyle": "solid",
"strokeWidth": 2,
"strokeStyle": "solid",
"roughness": 1,
"opacity": 100,
"groupIds": [],
"frameId": null,
"roundness": null,
"seed": 394088307,
"version": 43,
"versionNonce": 1073759923,
"isDeleted": false,
"boundElements": null,
"updated": 1748333674186,
"link": null,
"locked": false,
"text": "应用服务详情",
"fontSize": 20,
"fontFamily": 1,
"textAlign": "left",
"verticalAlign": "top",
"baseline": 18,
"containerId": null,
"originalText": "应用服务详情",
"lineHeight": 1.25
},
{
"id": "VX6SxBDx9cEiaH27rfs6C",
"type": "rectangle",
"x": 701,
"y": 434,
"width": 588,
"height": 247,
"angle": 0,
"strokeColor": "#1e1e1e",
"backgroundColor": "transparent",
"fillStyle": "solid",
"strokeWidth": 2,
"strokeStyle": "solid",
"roughness": 1,
"opacity": 100,
"groupIds": [],
"frameId": null,
"roundness": {
"type": 3
},
"seed": 1149948371,
"version": 75,
"versionNonce": 1727971485,
"isDeleted": false,
"boundElements": null,
"updated": 1748333161852,
"link": null,
"locked": false
},
{
"id": "kteNSyTy8ofeMtdKUfSuX",
"type": "rectangle",
"x": 725,
"y": 453,
"width": 259,
"height": 92,
"angle": 0,
"strokeColor": "#1e1e1e",
"backgroundColor": "transparent",
"fillStyle": "solid",
"strokeWidth": 2,
"strokeStyle": "solid",
"roughness": 1,
"opacity": 100,
"groupIds": [],
"frameId": null,
"roundness": null,
"seed": 507310227,
"version": 87,
"versionNonce": 1662500125,
"isDeleted": false,
"boundElements": null,
"updated": 1748333222852,
"link": null,
"locked": false
},
{
"id": "XRqTFOlDob8bvET8WmRXh",
"type": "rectangle",
"x": 727,
"y": 561,
"width": 259,
"height": 99,
"angle": 0,
"strokeColor": "#1e1e1e",
"backgroundColor": "transparent",
"fillStyle": "solid",
"strokeWidth": 2,
"strokeStyle": "solid",
"roughness": 1,
"opacity": 100,
"groupIds": [],
"frameId": null,
"roundness": null,
"seed": 526031859,
"version": 120,
"versionNonce": 1748182365,
"isDeleted": false,
"boundElements": [],
"updated": 1748333652567,
"link": null,
"locked": false
},
{
"id": "Q79QzFszyuPUYlD-4fPOg",
"type": "rectangle",
"x": 1002,
"y": 563,
"width": 265,
"height": 99,
"angle": 0,
"strokeColor": "#1e1e1e",
"backgroundColor": "transparent",
"fillStyle": "solid",
"strokeWidth": 2,
"strokeStyle": "solid",
"roughness": 1,
"opacity": 100,
"groupIds": [],
"frameId": null,
"roundness": null,
"seed": 1819422483,
"version": 175,
"versionNonce": 1005446685,
"isDeleted": false,
"boundElements": null,
"updated": 1748333277320,
"link": null,
"locked": false
},
{
"id": "HjXOgBul2HmGUt01jIIIu",
"type": "rectangle",
"x": 999,
"y": 454,
"width": 268,
"height": 89,
"angle": 0,
"strokeColor": "#1e1e1e",
"backgroundColor": "transparent",
"fillStyle": "solid",
"strokeWidth": 2,
"strokeStyle": "solid",
"roughness": 1,
"opacity": 100,
"groupIds": [],
"frameId": null,
"roundness": null,
"seed": 1125336787,
"version": 97,
"versionNonce": 608291133,
"isDeleted": false,
"boundElements": null,
"updated": 1748333226386,
"link": null,
"locked": false
},
{
"id": "8UZKPKisATsxYokL4qyi3",
"type": "text",
"x": 792,
"y": 489,
"width": 80.37997436523438,
"height": 25,
"angle": 0,
"strokeColor": "#1e1e1e",
"backgroundColor": "transparent",
"fillStyle": "solid",
"strokeWidth": 2,
"strokeStyle": "solid",
"roughness": 1,
"opacity": 100,
"groupIds": [],
"frameId": null,
"roundness": null,
"seed": 304901107,
"version": 13,
"versionNonce": 2113962419,
"isDeleted": false,
"boundElements": null,
"updated": 1748333644582,
"link": null,
"locked": false,
"text": "CPU监控",
"fontSize": 20,
"fontFamily": 1,
"textAlign": "left",
"verticalAlign": "top",
"baseline": 18,
"containerId": null,
"originalText": "CPU监控",
"lineHeight": 1.25
},
{
"id": "LhBKk2Z5fMm0_Nc5xAyWj",
"type": "text",
"x": 1089,
"y": 493,
"width": 80,
"height": 25,
"angle": 0,
"strokeColor": "#1e1e1e",
"backgroundColor": "transparent",
"fillStyle": "solid",
"strokeWidth": 2,
"strokeStyle": "solid",
"roughness": 1,
"opacity": 100,
"groupIds": [],
"frameId": null,
"roundness": null,
"seed": 658872755,
"version": 17,
"versionNonce": 1956372253,
"isDeleted": false,
"boundElements": null,
"updated": 1748333649997,
"link": null,
"locked": false,
"text": "内存监控",
"fontSize": 20,
"fontFamily": 1,
"textAlign": "left",
"verticalAlign": "top",
"baseline": 18,
"containerId": null,
"originalText": "内存监控",
"lineHeight": 1.25
},
{
"id": "DLtuS5siK48XuLWBFD-9a",
"type": "text",
"x": 799,
"y": 606,
"width": 80,
"height": 25,
"angle": 0,
"strokeColor": "#1e1e1e",
"backgroundColor": "transparent",
"fillStyle": "solid",
"strokeWidth": 2,
"strokeStyle": "solid",
"roughness": 1,
"opacity": 100,
"groupIds": [],
"frameId": null,
"roundness": null,
"seed": 1761901149,
"version": 16,
"versionNonce": 381372627,
"isDeleted": false,
"boundElements": null,
"updated": 1748333655681,
"link": null,
"locked": false,
"text": "磁盘监控",
"fontSize": 20,
"fontFamily": 1,
"textAlign": "left",
"verticalAlign": "top",
"baseline": 18,
"containerId": null,
"originalText": "磁盘监控",
"lineHeight": 1.25
},
{
"id": "QwA3rZceG1ZzqXAFzt6A-",
"type": "text",
"x": 1082,
"y": 608,
"width": 80,
"height": 25,
"angle": 0,
"strokeColor": "#1e1e1e",
"backgroundColor": "transparent",
"fillStyle": "solid",
"strokeWidth": 2,
"strokeStyle": "solid",
"roughness": 1,
"opacity": 100,
"groupIds": [],
"frameId": null,
"roundness": null,
"seed": 1404125939,
"version": 44,
"versionNonce": 741476253,
"isDeleted": false,
"boundElements": null,
"updated": 1748333665714,
"link": null,
"locked": false,
"text": "网络监控",
"fontSize": 20,
"fontFamily": 1,
"textAlign": "left",
"verticalAlign": "top",
"baseline": 18,
"containerId": null,
"originalText": "网络监控",
"lineHeight": 1.25
},
{
"id": "apI_6fXzwVGjmfgjZd9vc",
"type": "rectangle",
"x": 745,
"y": 275,
"width": 197,
"height": 35,
"angle": 0,
"strokeColor": "#1e1e1e",
"backgroundColor": "transparent",
"fillStyle": "solid",
"strokeWidth": 2,
"strokeStyle": "solid",
"roughness": 1,
"opacity": 100,
"groupIds": [],
"frameId": null,
"roundness": null,
"seed": 2017307229,
"version": 24,
"versionNonce": 345328883,
"isDeleted": false,
"boundElements": [
{
"type": "text",
"id": "vaW9NveNZiomtR-GQx4Lo"
}
],
"updated": 1748333693804,
"link": null,
"locked": false
},
{
"id": "vaW9NveNZiomtR-GQx4Lo",
"type": "text",
"x": 823.5,
"y": 280,
"width": 40,
"height": 25,
"angle": 0,
"strokeColor": "#1e1e1e",
"backgroundColor": "transparent",
"fillStyle": "solid",
"strokeWidth": 2,
"strokeStyle": "solid",
"roughness": 1,
"opacity": 100,
"groupIds": [],
"frameId": null,
"roundness": null,
"seed": 1275257693,
"version": 11,
"versionNonce": 1774693075,
"isDeleted": false,
"boundElements": null,
"updated": 1748333695996,
"link": null,
"locked": false,
"text": "名称",
"fontSize": 20,
"fontFamily": 1,
"textAlign": "center",
"verticalAlign": "middle",
"baseline": 18,
"containerId": "apI_6fXzwVGjmfgjZd9vc",
"originalText": "名称",
"lineHeight": 1.25
},
{
"id": "2qOZxK9JX8qNvqvQFYJ7N",
"type": "rectangle",
"x": 1002,
"y": 274,
"width": 260,
"height": 36,
"angle": 0,
"strokeColor": "#1e1e1e",
"backgroundColor": "transparent",
"fillStyle": "solid",
"strokeWidth": 2,
"strokeStyle": "solid",
"roughness": 1,
"opacity": 100,
"groupIds": [],
"frameId": null,
"roundness": null,
"seed": 988476787,
"version": 84,
"versionNonce": 55278291,
"isDeleted": false,
"boundElements": [
{
"type": "text",
"id": "L0Fzyx5mNl_ogCJ1W2bxN"
}
],
"updated": 1748333709824,
"link": null,
"locked": false
},
{
"id": "L0Fzyx5mNl_ogCJ1W2bxN",
"type": "text",
"x": 1112,
"y": 279.5,
"width": 40,
"height": 25,
"angle": 0,
"strokeColor": "#1e1e1e",
"backgroundColor": "transparent",
"fillStyle": "solid",
"strokeWidth": 2,
"strokeStyle": "solid",
"roughness": 1,
"opacity": 100,
"groupIds": [],
"frameId": null,
"roundness": null,
"seed": 1971294013,
"version": 78,
"versionNonce": 2058503347,
"isDeleted": false,
"boundElements": null,
"updated": 1748333712653,
"link": null,
"locked": false,
"text": "描述",
"fontSize": 20,
"fontFamily": 1,
"textAlign": "center",
"verticalAlign": "middle",
"baseline": 18,
"containerId": "2qOZxK9JX8qNvqvQFYJ7N",
"originalText": "描述",
"lineHeight": 1.25
},
{
"id": "RnVYRNi85nQkPjwN6Txqh",
"type": "rectangle",
"x": 745,
"y": 328,
"width": 516,
"height": 71,
"angle": 0,
"strokeColor": "#1e1e1e",
"backgroundColor": "transparent",
"fillStyle": "solid",
"strokeWidth": 2,
"strokeStyle": "solid",
"roughness": 1,
"opacity": 100,
"groupIds": [],
"frameId": null,
"roundness": null,
"seed": 1280898035,
"version": 62,
"versionNonce": 616946067,
"isDeleted": false,
"boundElements": [
{
"type": "text",
"id": "XsKpmAsx9pPYjvfrXMGmM"
}
],
"updated": 1748333736188,
"link": null,
"locked": false
},
{
"id": "XsKpmAsx9pPYjvfrXMGmM",
"type": "text",
"x": 895.880012512207,
"y": 351,
"width": 214.23997497558594,
"height": 25,
"angle": 0,
"strokeColor": "#1e1e1e",
"backgroundColor": "transparent",
"fillStyle": "solid",
"strokeWidth": 2,
"strokeStyle": "solid",
"roughness": 1,
"opacity": 100,
"groupIds": [],
"frameId": null,
"roundness": null,
"seed": 399921075,
"version": 47,
"versionNonce": 531252787,
"isDeleted": false,
"boundElements": null,
"updated": 1748333746705,
"link": null,
"locked": false,
"text": "节点列表节点ip等",
"fontSize": 20,
"fontFamily": 1,
"textAlign": "center",
"verticalAlign": "middle",
"baseline": 18,
"containerId": "RnVYRNi85nQkPjwN6Txqh",
"originalText": "节点列表节点ip等",
"lineHeight": 1.25
},
{
"id": "T2aicn5huf1uUB_yHb5hN",
"type": "text",
"x": 505,
"y": 352,
"width": 96,
"height": 40,
"angle": 0,
"strokeColor": "#1e1e1e",
"backgroundColor": "transparent",
"fillStyle": "solid",
"strokeWidth": 2,
"strokeStyle": "solid",
"roughness": 1,
"opacity": 100,
"groupIds": [],
"frameId": null,
"roundness": null,
"seed": 26603325,
"version": 62,
"versionNonce": 1313608797,
"isDeleted": false,
"boundElements": null,
"updated": 1748333817863,
"link": null,
"locked": false,
"text": "轮播选择\n右边跟着变化",
"fontSize": 16,
"fontFamily": 1,
"textAlign": "left",
"verticalAlign": "top",
"baseline": 34,
"containerId": null,
"originalText": "轮播选择\n右边跟着变化",
"lineHeight": 1.25
}
],
"appState": {
"gridSize": null,
"viewBackgroundColor": "#ffffff"
},
"files": {}
}