Skip to content

Commit cee2c9e

Browse files
💄add readme by english
1 parent b0e4d29 commit cee2c9e

File tree

3 files changed

+281
-58
lines changed

3 files changed

+281
-58
lines changed

README-CH.md

+222
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,222 @@
1+
<p align="center">
2+
<img width="400" src="https://gitee.com/d__isaster/cornucopia/raw/master/img/fast-mq.png">
3+
</p>
4+
5+
## 🔥特性(Features)
6+
- 🚀 开箱即用
7+
- 🍄 延时队列
8+
- 🔆 ACK机制
9+
- 📦 异步通信
10+
- 🎨 消息故障修复
11+
- 🌕 死信队列处理
12+
- 🌪️ 消息、消费组、消费者监控管理
13+
- 💫 灵活接口幂等控制
14+
- 🪐 支持redis单机、主从、集群
15+
- ..........(待续)
16+
## 🖥 环境要求 (Environment Required)
17+
- redis v6.0.0+
18+
- springboot v2.6.5
19+
- jdk 1.8+
20+
- ......
21+
22+
## 🌎 整体架构 (Architecture)
23+
24+
....(待续)
25+
26+
## ☀️ 快速开始(Quick Start)
27+
28+
### 依赖 (Dependency)
29+
30+
```java
31+
##此版本还未有监控页面
32+
<dependency>
33+
<groupId>io.github.disaster1-tesk</groupId>
34+
<artifactId>fast-mq-core</artifactId>
35+
<version>1.3.0</version>
36+
</dependency>
37+
```
38+
### 队列 (Queue)
39+
#### 生产者 (Producer)
40+
注入FastMQTemplate即可使用
41+
```java
42+
public class FastMQTemplateTest extends BaseTest {
43+
@Autowired
44+
private FastMQTemplate fastMQTemplate;
45+
46+
47+
@Test
48+
public void sendMsgTest() {
49+
HashMap<String, Object> msg = Maps.newHashMap();
50+
msg.put("name", "disaster");
51+
msg.put("age", 20);
52+
fastMQTemplate.sendMsgAsync("disaster_topic", msg);
53+
fastMQTemplate.sendMsgAsync("disaster_topic", msg);
54+
fastMQTemplate.sendMsgAsync(FastMQConstant.DEFAULT_TOPIC, msg);
55+
while (true){
56+
57+
}
58+
}
59+
}
60+
61+
```
62+
#### 消费者(Consumer)
63+
```java
64+
65+
/**
66+
* 不使用注解,则使用框架默认的topic和consumername
67+
*
68+
*/
69+
@Service
70+
@Slf4j
71+
public class FastMQConsumerTest implements FastMQListener {
72+
@Override
73+
public void onMessage(Object o) {
74+
log.info("result = {}", o);
75+
}
76+
}
77+
78+
/**
79+
* 使用注解可指定topic和consumername,同时还支持接口幂等处理
80+
*
81+
*/
82+
@Service
83+
@FastMQMessageListener(idempotent = true,groupName = "disaster",consumeName = "disaster1",topic = "disaster_topic", readSize = 0)
84+
@Slf4j
85+
public class FastMQConsumerAnnotationTest implements FastMQListener{
86+
@Override
87+
public void onMessage(Object t) {
88+
log.info("result = {}", t);
89+
}
90+
}
91+
```
92+
### 延时队列 (Delay Queue)
93+
#### 生产者 (Producer)
94+
注入FastMQTemplate即可使用
95+
```java
96+
public class FastMQDelayTemplateTest extends BaseTest {
97+
@Autowired
98+
private FastMQDelayTemplate fastMQDelayTemplate;
99+
100+
@Test
101+
public void sendMsgTest() throws InterruptedException {
102+
Thread.sleep(2000l);
103+
fastMQDelayTemplate.msgEnQueue("hello", 20, null, TimeUnit.SECONDS);
104+
while (true) {
105+
}
106+
}
107+
}
108+
109+
```
110+
#### 消费者(Consumer)
111+
```java
112+
/**
113+
* 不使用注解则使用框架默认队列名和线程池
114+
*/
115+
@Service
116+
@Slf4j
117+
public class FastMQDelayConsumerTest implements FastMQDelayListener {
118+
@Override
119+
public void onMessage(Object t) throws Throwable {
120+
log.info("result = {}", t);
121+
}
122+
}
123+
124+
/**
125+
* 使用注解可自定义队列名称与线程池
126+
*/
127+
@FastMQDelayMessageListener(queueName = "test",executorName = "test_executor")
128+
@Service
129+
@Slf4j
130+
public class FastMQDelayConsumerAnnotationTest implements FastMQDelayListener {
131+
@Override
132+
public void onMessage(Object t) throws Throwable {
133+
log.info("result = {}", t);
134+
}
135+
}
136+
```
137+
## 💐 配置 (Configuration)
138+
### 🦫Redission配置项
139+
#### 1.fast-mq内置配置
140+
fast-mq支持通过YAML配置Redission单机、主从、集群
141+
```
142+
## 单机版本
143+
redisson:
144+
server:
145+
host: 127.0.0.1
146+
port: 6379
147+
database: 0
148+
deployment: stand_alone
149+
## 主从版本
150+
redisson:
151+
server:
152+
host: 127.0.0.1
153+
port: 6379
154+
database: 0
155+
nodes: 127.0.0.1:xxx,127.0.0.1:xxx,127.0.0.1:xxx
156+
master: mymaster
157+
deployment: master_slave
158+
## 集群
159+
160+
server:
161+
host: 127.0.0.1
162+
port: 6379
163+
database: 0
164+
nodes: 127.0.0.1:xxx,127.0.0.1:xxx,127.0.0.1:xxx
165+
deployment: cluster
166+
```
167+
#### 2.用户自定义
168+
如果不想使用fast-mq提供的Redission-YAML配置,则只需要在springboot项目中实例化一个RedissonClient对象并被spring管理即可
169+
```java
170+
@Configuration
171+
public class RedissionConfig {
172+
173+
@Bean
174+
public RedissonClient redissonClient() {
175+
Config config = new Config();
176+
SingleServerConfig singleServerConfig = config.useSingleServer();
177+
singleServerConfig.setAddress("redis://" + "127.0.0.1:6379");
178+
singleServerConfig.setDatabase(1);
179+
singleServerConfig.setPassword("123456");
180+
return Redisson.create(config);
181+
}
182+
}
183+
```
184+
### 🦦FastMQ配置项
185+
186+
```
187+
fastmq:
188+
config:
189+
#是否开启fastmq
190+
enable: false
191+
# 每次拉取数据的量
192+
fetchMessageSize: 5
193+
#每次拉取PendingList的大小
194+
pullPendingListSize: 1000
195+
#死信门槛(秒)
196+
deadLetterThreshold: 32
197+
#是否从头开始订阅消息
198+
isStartFromHead: true
199+
#超过了该长度stream前面部分会被持久化(非严格模式——MAXLEN~)
200+
trimThreshold: 10000
201+
#是否是异步
202+
isAsync: false
203+
executor:
204+
#拉取默认主题信息的周期
205+
pullDefaultTopicMessagesPeriod: 10
206+
#检查PendingList周期
207+
pullTopicMessagesPeriod: 1
208+
time-unit: seconds
209+
#第一次延迟执行的时间
210+
initial-delay: 1
211+
#线程池的核心线程数,同步时调此参数能有效提高效率,如果采用的是异步消费的方式,使用默认配置即可
212+
executor-core-size: 20
213+
claim:
214+
#认领门槛(单位毫秒)
215+
claimThreshold: 20
216+
time-unit: milliseconds
217+
idle:
218+
#检查consumer不活跃的门槛(单位秒)
219+
pendingListIdleThreshold: 10
220+
time-unit: seconds
221+
```
222+

0 commit comments

Comments
 (0)