Skip to content

Commit e64edb0

Browse files
committed
更新readme
1 parent 4d37263 commit e64edb0

File tree

3 files changed

+134
-21
lines changed

3 files changed

+134
-21
lines changed

README.md

Lines changed: 23 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,27 @@
11
# LightMQ
22

3-
## 介绍
3+
[English](README.md) | [中文](./README_CN.md)
44

5-
基于数据库的消息队列,目前支持的数据库:
5+
## Introduction
6+
7+
Database-based message queues, currently supported databases.:
68

79
1. MongoDB
810
2. SqlServer
911

10-
特性
12+
Features
1113

12-
1. 支持重试
13-
2. 支持多队列
14-
3. 支持并发消费
14+
1. Supports retries
15+
2. Supports multiple queues
16+
3. Supports concurrent consumption
1517

16-
## 测试覆盖率
18+
## Test Coverage
1719

18-
![测试截图](./doc/test_coverage_20240822100230.jpg)
20+
![test screenshot](./doc/test_coverage_20240822100230.jpg)
1921

20-
## 使用方式
22+
## Usage
2123

22-
初始化
24+
Initialize
2325

2426
```c#
2527

@@ -31,7 +33,7 @@ serviceCollection.AddLightMQ(it =>
3133

3234
```
3335

34-
新增消费者
36+
Add a consumer
3537

3638
```c#
3739
public class Test2Consumer:IMessageConsumer
@@ -48,7 +50,7 @@ public class Test2Consumer:IMessageConsumer
4850

4951
public async Task<bool> ConsumeAsync(string message, CancellationToken cancellationToken)
5052
{
51-
Console.WriteLine("消费消息"+message);
53+
Console.WriteLine("consume message:"+message);
5254
await Task.Delay(2_000,cancellationToken);
5355
return true;
5456
}
@@ -57,47 +59,47 @@ public class Test2Consumer:IMessageConsumer
5759
}
5860
```
5961

60-
注册消费者
62+
Register the consumer
6163

6264
```C#
6365
builder.Services.AddScoped<TestConsumer>();
6466
```
6567

66-
## 消费者配置
68+
## Consumer Options
6769

6870
```c#
6971
public class ConsumerOptions
7072
{
7173
/// <summary>
72-
/// 主题
74+
/// Topic
7375
/// </summary>
7476
public string Topic { get; set; }
7577

7678
/// <summary>
77-
/// 开启随机队列消费
79+
/// Enable Random Queue
7880
/// </summary>
7981
public bool EnableRandomQueue {get;set;}
8082

8183
/// <summary>
82-
/// 拉取间隔
84+
/// Poll Interval
8385
/// </summary>
8486
public TimeSpan PollInterval { get; set; }=TimeSpan.FromSeconds(2);
8587

8688
/// <summary>
87-
/// 重试次数(不包括第一次执行)
89+
/// Retry Count (not including the first execution)
8890
/// </summary>
8991
public int RetryCount { get; set; } = 0;
9092

9193
/// <summary>
92-
/// 重试间隔
94+
/// Retry Interval
9395
/// </summary>
9496
public TimeSpan RetryInterval { get; set; }=TimeSpan.FromSeconds(5);
9597

9698
/// <summary>
97-
/// 并发数量
99+
/// Concurrent Number
98100
/// </summary>
99101
public int ParallelNum { get; set; }
100102
}
101103
```
102104

103-
更多可以查看Sample示例
105+
More examples can be found under the Sample category.

README_CN.md

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
# LightMQ
2+
3+
[English](README.md) | [中文](./README_CN.md)
4+
5+
## 介绍
6+
7+
基于数据库的消息队列,目前支持的数据库:
8+
9+
1. MongoDB
10+
2. SqlServer
11+
12+
特性:
13+
14+
1. 支持重试
15+
2. 支持多队列
16+
3. 支持并发消费
17+
18+
## 测试覆盖率
19+
20+
![测试截图](./doc/test_coverage_20240822100230.jpg)
21+
22+
## 使用方式
23+
24+
初始化:
25+
26+
```c#
27+
28+
serviceCollection.AddLightMQ(it =>
29+
{
30+
// it.UseSqlServer("Data Source=.;Initial Catalog=Test;User ID=sa;Password=Abc12345;");
31+
it.UseMongoDB("mongodb://localhost:27017","Test");
32+
});
33+
34+
```
35+
36+
新增消费者:
37+
38+
```c#
39+
public class Test2Consumer:IMessageConsumer
40+
{
41+
42+
public ConsumerOptions GetOptions()
43+
{
44+
return new ConsumerOptions()
45+
{
46+
ParallelNum = 1,
47+
Topic = "test"
48+
};
49+
}
50+
51+
public async Task<bool> ConsumeAsync(string message, CancellationToken cancellationToken)
52+
{
53+
Console.WriteLine("消费消息"+message);
54+
await Task.Delay(2_000,cancellationToken);
55+
return true;
56+
}
57+
58+
59+
}
60+
```
61+
62+
注册消费者:
63+
64+
```C#
65+
builder.Services.AddScoped<TestConsumer>();
66+
```
67+
68+
## 消费者配置
69+
70+
```c#
71+
public class ConsumerOptions
72+
{
73+
/// <summary>
74+
/// 主题
75+
/// </summary>
76+
public string Topic { get; set; }
77+
78+
/// <summary>
79+
/// 开启随机队列消费
80+
/// </summary>
81+
public bool EnableRandomQueue {get;set;}
82+
83+
/// <summary>
84+
/// 拉取间隔
85+
/// </summary>
86+
public TimeSpan PollInterval { get; set; }=TimeSpan.FromSeconds(2);
87+
88+
/// <summary>
89+
/// 重试次数(不包括第一次执行)
90+
/// </summary>
91+
public int RetryCount { get; set; } = 0;
92+
93+
/// <summary>
94+
/// 重试间隔
95+
/// </summary>
96+
public TimeSpan RetryInterval { get; set; }=TimeSpan.FromSeconds(5);
97+
98+
/// <summary>
99+
/// 并发数量
100+
/// </summary>
101+
public int ParallelNum { get; set; }
102+
}
103+
```
104+
105+
更多可以查看Sample示例

src/LightMQ.sln

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,12 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{64A31597-3
2020
EndProject
2121
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LightMQ.IntegrationTest", "LightMQ.IntegrationTest\LightMQ.IntegrationTest.csproj", "{3DE3B192-F395-478B-BBAD-A40E403AD8FF}"
2222
EndProject
23+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "doc", "doc", "{E018A9B3-9951-401B-A39F-85F3D3A5426B}"
24+
ProjectSection(SolutionItems) = preProject
25+
..\README.md = ..\README.md
26+
..\README_CN.md = ..\README_CN.md
27+
EndProjectSection
28+
EndProject
2329
Global
2430
GlobalSection(SolutionConfigurationPlatforms) = preSolution
2531
Debug|Any CPU = Debug|Any CPU

0 commit comments

Comments
 (0)