Skip to content

Commit f477b09

Browse files
Remove database queue mode (#102)
* Improve the implementation mechanism of queue mode. #96 * refactor the code . * add Copyright & License description into header text of code files. * refactor * set version to 2.2.0 * update unit tests. * add exception class to process the publish send and subscriber exectution exception * modify first retry time to three. * code refactor. * add retry mechanism * code refactor * refactor consumer execution * fix spell error * remove dashboard `processing ` content. * Modify the retry to retry the message only 4 minutes ago. * update samples * update ci configuration.
1 parent 9829f2a commit f477b09

File tree

271 files changed

+2671
-3044
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

271 files changed

+2671
-3044
lines changed

CAP.sln

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -54,15 +54,11 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DotNetCore.CAP.MySql.Test",
5454
EndProject
5555
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Sample.RabbitMQ.MySql", "samples\Sample.RabbitMQ.MySql\Sample.RabbitMQ.MySql.csproj", "{9F3F9BFE-7B6A-4A7A-A6E6-8B517D611873}"
5656
EndProject
57-
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Sample.RabbitMQ.SqlServer", "samples\Sample.RabbitMQ.SqlServer\Sample.RabbitMQ.SqlServer.csproj", "{AF17B956-B79E-48B7-9B5B-EB15A386B112}"
58-
EndProject
5957
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DotNetCore.CAP.PostgreSql", "src\DotNetCore.CAP.PostgreSql\DotNetCore.CAP.PostgreSql.csproj", "{82C403AB-ED68-4084-9A1D-11334F9F08F9}"
6058
EndProject
61-
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Sample.RabbitMQ.PostgreSql", "samples\Sample.RabbitMQ.PostgreSql\Sample.RabbitMQ.PostgreSql.csproj", "{A17E8E72-DFFC-4822-BB38-73D59A8B264E}"
62-
EndProject
6359
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DotNetCore.CAP.PostgreSql.Test", "test\DotNetCore.CAP.PostgreSql.Test\DotNetCore.CAP.PostgreSql.Test.csproj", "{7CA3625D-1817-4695-881D-7E79A1E1DED2}"
6460
EndProject
65-
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Sample.Kafka.SqlServer", "samples\Sample.Kafka.SqlServer\Sample.Kafka.SqlServer.csproj", "{573B4D39-5489-48B3-9B6C-5234249CB980}"
61+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Sample.Kafka.MySql", "samples\Sample.Kafka.SqlServer\Sample.Kafka.MySql.csproj", "{573B4D39-5489-48B3-9B6C-5234249CB980}"
6662
EndProject
6763
Global
6864
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -105,18 +101,10 @@ Global
105101
{9F3F9BFE-7B6A-4A7A-A6E6-8B517D611873}.Debug|Any CPU.Build.0 = Debug|Any CPU
106102
{9F3F9BFE-7B6A-4A7A-A6E6-8B517D611873}.Release|Any CPU.ActiveCfg = Release|Any CPU
107103
{9F3F9BFE-7B6A-4A7A-A6E6-8B517D611873}.Release|Any CPU.Build.0 = Release|Any CPU
108-
{AF17B956-B79E-48B7-9B5B-EB15A386B112}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
109-
{AF17B956-B79E-48B7-9B5B-EB15A386B112}.Debug|Any CPU.Build.0 = Debug|Any CPU
110-
{AF17B956-B79E-48B7-9B5B-EB15A386B112}.Release|Any CPU.ActiveCfg = Release|Any CPU
111-
{AF17B956-B79E-48B7-9B5B-EB15A386B112}.Release|Any CPU.Build.0 = Release|Any CPU
112104
{82C403AB-ED68-4084-9A1D-11334F9F08F9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
113105
{82C403AB-ED68-4084-9A1D-11334F9F08F9}.Debug|Any CPU.Build.0 = Debug|Any CPU
114106
{82C403AB-ED68-4084-9A1D-11334F9F08F9}.Release|Any CPU.ActiveCfg = Release|Any CPU
115107
{82C403AB-ED68-4084-9A1D-11334F9F08F9}.Release|Any CPU.Build.0 = Release|Any CPU
116-
{A17E8E72-DFFC-4822-BB38-73D59A8B264E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
117-
{A17E8E72-DFFC-4822-BB38-73D59A8B264E}.Debug|Any CPU.Build.0 = Debug|Any CPU
118-
{A17E8E72-DFFC-4822-BB38-73D59A8B264E}.Release|Any CPU.ActiveCfg = Release|Any CPU
119-
{A17E8E72-DFFC-4822-BB38-73D59A8B264E}.Release|Any CPU.Build.0 = Release|Any CPU
120108
{7CA3625D-1817-4695-881D-7E79A1E1DED2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
121109
{7CA3625D-1817-4695-881D-7E79A1E1DED2}.Debug|Any CPU.Build.0 = Debug|Any CPU
122110
{7CA3625D-1817-4695-881D-7E79A1E1DED2}.Release|Any CPU.ActiveCfg = Release|Any CPU
@@ -139,9 +127,7 @@ Global
139127
{FA15685A-778A-4D2A-A2FE-27FAD2FFA65B} = {9B2AE124-6636-4DE9-83A3-70360DABD0C4}
140128
{80A84F62-1558-427B-BA74-B47AA8A665B5} = {C09CDAB0-6DD4-46E9-B7F3-3EF2A4741EA0}
141129
{9F3F9BFE-7B6A-4A7A-A6E6-8B517D611873} = {3A6B6931-A123-477A-9469-8B468B5385AF}
142-
{AF17B956-B79E-48B7-9B5B-EB15A386B112} = {3A6B6931-A123-477A-9469-8B468B5385AF}
143130
{82C403AB-ED68-4084-9A1D-11334F9F08F9} = {9B2AE124-6636-4DE9-83A3-70360DABD0C4}
144-
{A17E8E72-DFFC-4822-BB38-73D59A8B264E} = {3A6B6931-A123-477A-9469-8B468B5385AF}
145131
{7CA3625D-1817-4695-881D-7E79A1E1DED2} = {C09CDAB0-6DD4-46E9-B7F3-3EF2A4741EA0}
146132
{573B4D39-5489-48B3-9B6C-5234249CB980} = {3A6B6931-A123-477A-9469-8B468B5385AF}
147133
EndGlobalSection

ConfigureMSDTC.ps1

Lines changed: 0 additions & 40 deletions
This file was deleted.

appveyor.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ services:
1111
- mysql
1212
- postgresql
1313
build_script:
14-
- ps: ./ConfigureMSDTC.ps1
1514
- ps: ./build.ps1
1615
test: off
1716
artifacts:

build/version.props

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<Project>
22
<PropertyGroup>
33
<VersionMajor>2</VersionMajor>
4-
<VersionMinor>1</VersionMinor>
5-
<VersionPatch>4</VersionPatch>
4+
<VersionMinor>2</VersionMinor>
5+
<VersionPatch>0</VersionPatch>
66
<VersionQuality></VersionQuality>
77
<VersionPrefix>$(VersionMajor).$(VersionMinor).$(VersionPatch)</VersionPrefix>
88
</PropertyGroup>

samples/Sample.Kafka.SqlServer/AppDbContext.cs

Lines changed: 0 additions & 14 deletions
This file was deleted.

samples/Sample.Kafka.SqlServer/CmsContentSerializer.cs

Lines changed: 0 additions & 50 deletions
This file was deleted.
Lines changed: 14 additions & 108 deletions
Original file line numberDiff line numberDiff line change
@@ -1,137 +1,43 @@
11
using System;
2-
using System.Diagnostics;
32
using System.Threading.Tasks;
43
using DotNetCore.CAP;
5-
using Microsoft.AspNetCore.Authorization;
64
using Microsoft.AspNetCore.Mvc;
7-
using Newtonsoft.Json;
5+
using MySql.Data.MySqlClient;
86

9-
namespace Sample.Kafka.SqlServer.Controllers
7+
namespace Sample.Kafka.MySql.Controllers
108
{
11-
public class Person
12-
{
13-
[JsonProperty("id")]
14-
public string Id { get; set; }
15-
16-
[JsonProperty("uname")]
17-
public string Name { get; set; }
18-
19-
public HAHA Haha { get; set; }
20-
21-
public override string ToString()
22-
{
23-
return "Name:" + Name + ";Id:" + Id + "Haha:" + Haha?.ToString();
24-
}
25-
}
26-
27-
public class HAHA
28-
{
29-
[JsonProperty("id")]
30-
public string Id { get; set; }
31-
32-
[JsonProperty("uname")]
33-
public string Name { get; set; }
34-
public override string ToString()
35-
{
36-
return "Name:" + Name + ";Id:" + Id;
37-
}
38-
}
39-
40-
419
[Route("api/[controller]")]
4210
public class ValuesController : Controller, ICapSubscribe
4311
{
4412
private readonly ICapPublisher _capBus;
45-
private readonly AppDbContext _dbContext;
4613

47-
public ValuesController(ICapPublisher producer, AppDbContext dbContext)
14+
public ValuesController(ICapPublisher producer)
4815
{
4916
_capBus = producer;
50-
_dbContext = dbContext;
5117
}
5218

53-
5419
[Route("~/publish")]
55-
public IActionResult PublishMessage()
20+
public async Task<IActionResult> PublishMessage()
5621
{
57-
var p = new Person
22+
using (var connection = new MySqlConnection("Server=192.168.10.110;Database=testcap;UserId=root;Password=123123;"))
5823
{
59-
Id = Guid.NewGuid().ToString(),
60-
Name = "杨晓东",
61-
Haha = new HAHA
62-
{
63-
Id = Guid.NewGuid().ToString(),
64-
Name = "1-1杨晓东",
65-
}
66-
};
67-
68-
_capBus.Publish("wl.yxd.test", p, "wl.yxd.test.callback");
69-
70-
71-
//_capBus.Publish("wl.cj.test", p);
72-
return Ok();
73-
}
74-
75-
[CapSubscribe("wl.yxd.test.callback")]
76-
public void KafkaTestCallback(Person p)
77-
{
78-
Console.WriteLine("回调内容:" + p);
79-
}
24+
connection.Open();
25+
var transaction = connection.BeginTransaction();
8026

27+
//your business code here
8128

82-
[CapSubscribe("wl.cj.test")]
83-
public string KafkaTestReceived(Person person)
84-
{
85-
Console.WriteLine(person);
86-
Debug.WriteLine(person);
87-
return "this is callback message";
88-
}
89-
90-
[Route("~/publishWithTrans")]
91-
public async Task<IActionResult> PublishMessageWithTransaction()
92-
{
93-
using (var trans = await _dbContext.Database.BeginTransactionAsync())
94-
{
95-
await _capBus.PublishAsync("sample.rabbitmq.mysql", "");
29+
await _capBus.PublishAsync("xxx.xxx.test2", 123456, transaction);
9630

97-
trans.Commit();
31+
transaction.Commit();
9832
}
99-
return Ok();
100-
}
101-
102-
[CapSubscribe("sample.rabbitmq.mysql33333", Group = "Test.Group")]
103-
public void KafkaTest22(Person person)
104-
{
105-
var aa = _dbContext.Database;
106-
107-
_dbContext.Dispose();
10833

109-
Console.WriteLine("[sample.kafka.sqlserver] message received " + person.ToString());
110-
Debug.WriteLine("[sample.kafka.sqlserver] message received " + person.ToString());
111-
}
112-
113-
//[CapSubscribe("sample.rabbitmq.mysql22222")]
114-
//public void KafkaTest22(DateTime time)
115-
//{
116-
// Console.WriteLine("[sample.kafka.sqlserver] message received " + time.ToString());
117-
// Debug.WriteLine("[sample.kafka.sqlserver] message received " + time.ToString());
118-
//}
119-
120-
[CapSubscribe("sample.rabbitmq.mysql22222")]
121-
public async Task<DateTime> KafkaTest33(DateTime time)
122-
{
123-
Console.WriteLine("[sample.kafka.sqlserver] message received " + time.ToString());
124-
Debug.WriteLine("[sample.kafka.sqlserver] message received " + time.ToString());
125-
return await Task.FromResult(time);
34+
return Ok("publish successful!");
12635
}
12736

128-
[NonAction]
129-
[CapSubscribe("sample.kafka.sqlserver3")]
130-
[CapSubscribe("sample.kafka.sqlserver4")]
131-
public void KafkaTest()
37+
[CapSubscribe("xxx.xxx.test2")]
38+
public void Test2(int value)
13239
{
133-
Console.WriteLine("[sample.kafka.sqlserver] message received");
134-
Debug.WriteLine("[sample.kafka.sqlserver] message received");
40+
Console.WriteLine(value);
13541
}
13642
}
13743
}

samples/Sample.Kafka.SqlServer/Program.cs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
1-
using System.IO;
2-
using Microsoft.AspNetCore;
3-
using Microsoft.AspNetCore.Builder;
1+
using Microsoft.AspNetCore;
42
using Microsoft.AspNetCore.Hosting;
5-
using Microsoft.Extensions.Configuration;
63

7-
namespace Sample.Kafka.SqlServer
4+
namespace Sample.Kafka.MySql
85
{
96
public class Program
107
{
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
{
2+
"iisSettings": {
3+
"windowsAuthentication": false,
4+
"anonymousAuthentication": true,
5+
"iisExpress": {
6+
"applicationUrl": "http://localhost:57172/",
7+
"sslPort": 0
8+
}
9+
},
10+
"profiles": {
11+
"IIS Express": {
12+
"commandName": "IISExpress",
13+
"launchBrowser": true,
14+
"launchUrl": "cap",
15+
"environmentVariables": {
16+
"ASPNETCORE_ENVIRONMENT": "Development"
17+
}
18+
},
19+
"Sample.Kafka.SqlServer": {
20+
"commandName": "Project",
21+
"launchBrowser": true,
22+
"launchUrl": "cap",
23+
"environmentVariables": {
24+
"ASPNETCORE_ENVIRONMENT": "Development"
25+
},
26+
"applicationUrl": "http://localhost:57174/"
27+
}
28+
}
29+
}

samples/Sample.Kafka.SqlServer/Sample.Kafka.SqlServer.csproj renamed to samples/Sample.Kafka.SqlServer/Sample.Kafka.MySql.csproj

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,21 @@
22

33
<PropertyGroup>
44
<TargetFramework>netcoreapp2.0</TargetFramework>
5-
<AssemblyName>Sample.Kafka.SqlServer</AssemblyName>
5+
<AssemblyName>Sample.Kafka.MySql</AssemblyName>
66
<WarningsAsErrors>NU1701</WarningsAsErrors>
77
<NoWarn>NU1701</NoWarn>
88
</PropertyGroup>
99

1010
<ItemGroup>
11-
<PackageReference Include="Microsoft.AspNetCore.All" Version="2.0.5" />
11+
<PackageReference Include="Microsoft.AspNetCore.All" Version="2.0.6" />
12+
<PackageReference Include="MySqlConnector" Version="0.37.1" />
1213
</ItemGroup>
1314
<ItemGroup>
1415
<DotNetCliToolReference Include="Microsoft.EntityFrameworkCore.Tools.DotNet" Version="2.0.0" />
1516
</ItemGroup>
1617
<ItemGroup>
1718
<ProjectReference Include="..\..\src\DotNetCore.CAP.Kafka\DotNetCore.CAP.Kafka.csproj" />
18-
<ProjectReference Include="..\..\src\DotNetCore.CAP.SqlServer\DotNetCore.CAP.SqlServer.csproj" />
19+
<ProjectReference Include="..\..\src\DotNetCore.CAP.MySql\DotNetCore.CAP.MySql.csproj" />
1920
<ProjectReference Include="..\..\src\DotNetCore.CAP\DotNetCore.CAP.csproj" />
2021
</ItemGroup>
2122

0 commit comments

Comments
 (0)