Skip to content

Commit c053860

Browse files
Release 2.2.2 (#121)
* fixed message enqueue exception in v2.2 * add log to samples * Improved log output. #114 * add default timeout configuration for kafka client. * fixed retry processor bugs. * Fixed kafka producer exception log without logging when publish message. * update version num to 2.2.2 * rename configuration options FailedCallback to FailedThresholdCallback * rename files name. * remove unused files. * modify the error comments. * update samples. * add logs.
1 parent bd66dc5 commit c053860

25 files changed

+198
-110
lines changed

build/version.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<PropertyGroup>
33
<VersionMajor>2</VersionMajor>
44
<VersionMinor>2</VersionMinor>
5-
<VersionPatch>1</VersionPatch>
5+
<VersionPatch>2</VersionPatch>
66
<VersionQuality></VersionQuality>
77
<VersionPrefix>$(VersionMajor).$(VersionMinor).$(VersionPatch)</VersionPrefix>
88
</PropertyGroup>

samples/Sample.Kafka.MySql/Controllers/ValuesController.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public async Task<IActionResult> PublishMessage()
3737
[CapSubscribe("xxx.xxx.test2")]
3838
public void Test2(int value)
3939
{
40-
Console.WriteLine(value);
40+
Console.WriteLine("Subscriber output message: " + value);
4141
}
4242
}
4343
}

samples/Sample.Kafka.MySql/Program.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using Microsoft.AspNetCore;
22
using Microsoft.AspNetCore.Hosting;
3+
using NLog.Web;
34

45
namespace Sample.Kafka.MySql
56
{
@@ -14,7 +15,11 @@ public static void Main(string[] args)
1415
public static IWebHost BuildWebHost(string[] args) =>
1516
WebHost.CreateDefaultBuilder(args)
1617
.UseStartup<Startup>()
18+
.ConfigureLogging((hostingContext, builder) =>
19+
{
20+
hostingContext.HostingEnvironment.ConfigureNLog("nlog.config");
21+
})
22+
.UseNLog()
1723
.Build();
18-
1924
}
2025
}

samples/Sample.Kafka.MySql/Sample.Kafka.MySql.csproj

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
<ItemGroup>
1111
<PackageReference Include="Microsoft.AspNetCore.All" Version="2.0.6" />
1212
<PackageReference Include="MySqlConnector" Version="0.38.0" />
13+
<PackageReference Include="NLog.Web.AspNetCore" Version="4.5.2" />
1314
<PackageReference Include="zipkin4net" Version="1.2.0" />
1415
</ItemGroup>
1516
<ItemGroup>
@@ -20,5 +21,10 @@
2021
<ProjectReference Include="..\..\src\DotNetCore.CAP.MySql\DotNetCore.CAP.MySql.csproj" />
2122
<ProjectReference Include="..\..\src\DotNetCore.CAP\DotNetCore.CAP.csproj" />
2223
</ItemGroup>
24+
<ItemGroup>
25+
<Content Update="nlog.config">
26+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
27+
</Content>
28+
</ItemGroup>
2329

2430
</Project>
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
3+
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
4+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
5+
autoReload="true"
6+
internalLogLevel="Warn"
7+
internalLogFile="logs/internal-nlog.txt">
8+
9+
<variable name="myLogLayout"
10+
value="---------------------------------------------------------------------------${newline}Date:${longdate} Level:${uppercase:${level}} User:${aspnet-user-identity}(${aspnet-request-ip}) Logger:${logger} URL:${aspnet-request-method} ${aspnet-request-url:IncludePort=true:IncludeQueryString=true} Action:${aspnet-mvc-action} ${newline}Message:${message} ${newline}${onexception:Exception:${exception:format=toString}}" />
11+
<extensions>
12+
<add assembly="NLog.Web.AspNetCore" />
13+
</extensions>
14+
15+
<!-- define various log targets -->
16+
<targets>
17+
<!-- write logs to file -->
18+
<target name="allfile" xsi:type="File" fileName="logs/cap-all-${shortdate}.log"
19+
layout="${myLogLayout}" />
20+
</targets>
21+
22+
<rules>
23+
<!--All logs, including from Microsoft-->
24+
<logger name="*" minlevel="Debug" writeTo="allfile" />
25+
</rules>
26+
</nlog>
Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,12 @@
1-
using System;
2-
using System.Collections.Generic;
3-
using System.Linq;
4-
using System.Threading.Tasks;
5-
using Microsoft.EntityFrameworkCore;
1+
using Microsoft.EntityFrameworkCore;
62

73
namespace Sample.RabbitMQ.MySql
84
{
95
public class AppDbContext : DbContext
106
{
117
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
128
{
13-
optionsBuilder.UseMySql("Server=localhost;Database=Sample.RabbitMQ.MySql;UserId=root;Password=123123;Allow User Variables=True");
14-
//optionsBuilder.UseMySql("Server=192.168.2.206;Database=Sample.RabbitMQ.MySql;UserId=root;Password=123123;");
9+
optionsBuilder.UseMySql("Server=192.168.10.110;Database=testcap;UserId=root;Password=123123;");
1510
}
1611
}
1712
}

samples/Sample.RabbitMQ.MySql/Controllers/ValuesController.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public ValuesController(AppDbContext dbContext, ICapPublisher capPublisher)
2121
public IActionResult PublishMessage()
2222
{
2323
_capBus.Publish("sample.rabbitmq.mysql", DateTime.Now);
24-
24+
2525
return Ok();
2626
}
2727

@@ -50,7 +50,7 @@ public async Task<IActionResult> PublishMessageWithTransaction()
5050
[CapSubscribe("sample.rabbitmq.mysql")]
5151
public void ReceiveMessage(DateTime time)
5252
{
53-
Console.WriteLine("[sample.rabbitmq.mysql] message received: "+ DateTime.Now.ToString() +" , sent time: " + time.ToString());
53+
Console.WriteLine("[sample.rabbitmq.mysql] message received: " + DateTime.Now + ",sent time: " + time);
5454
}
5555
}
5656
}
Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,6 @@
1-
using System;
2-
using System.Collections.Generic;
3-
using System.IO;
4-
using System.Linq;
5-
using System.Threading.Tasks;
6-
using Microsoft.AspNetCore;
7-
using Microsoft.AspNetCore.Builder;
1+
using Microsoft.AspNetCore;
82
using Microsoft.AspNetCore.Hosting;
9-
using Microsoft.Extensions.Configuration;
3+
using NLog.Web;
104

115
namespace Sample.RabbitMQ.MySql
126
{
@@ -20,6 +14,11 @@ public static void Main(string[] args)
2014
public static IWebHost BuildWebHost(string[] args) =>
2115
WebHost.CreateDefaultBuilder(args)
2216
.UseStartup<Startup>()
17+
.ConfigureLogging((hostingContext, builder) =>
18+
{
19+
hostingContext.HostingEnvironment.ConfigureNLog("nlog.config");
20+
})
21+
.UseNLog()
2322
.Build();
2423
}
2524
}

samples/Sample.RabbitMQ.MySql/Sample.RabbitMQ.MySql.csproj

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
<ItemGroup>
1313
<PackageReference Include="Microsoft.AspNetCore.All" Version="2.0.6" />
1414
<PackageReference Include="Pomelo.EntityFrameworkCore.MySql" Version="2.0.1" />
15+
<PackageReference Include="NLog.Web.AspNetCore" Version="4.5.2" />
1516
</ItemGroup>
1617
<ItemGroup>
1718
<DotNetCliToolReference Include="Microsoft.EntityFrameworkCore.Tools.DotNet" Version="2.0.0" />
@@ -21,5 +22,10 @@
2122
<ProjectReference Include="..\..\src\DotNetCore.CAP.RabbitMQ\DotNetCore.CAP.RabbitMQ.csproj" />
2223
<ProjectReference Include="..\..\src\DotNetCore.CAP\DotNetCore.CAP.csproj" />
2324
</ItemGroup>
25+
<ItemGroup>
26+
<Content Update="nlog.config">
27+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
28+
</Content>
29+
</ItemGroup>
2430

2531
</Project>
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
3+
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
4+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
5+
autoReload="true"
6+
internalLogLevel="Warn"
7+
internalLogFile="logs/internal-nlog.txt">
8+
9+
<variable name="myLogLayout"
10+
value="---------------------------------------------------------------------------${newline}Date:${longdate} Level:${uppercase:${level}} User:${aspnet-user-identity}(${aspnet-request-ip}) Logger:${logger} URL:${aspnet-request-method} ${aspnet-request-url:IncludePort=true:IncludeQueryString=true} Action:${aspnet-mvc-action} ${newline}Message:${message} ${newline}${onexception:Exception:${exception:format=toString}}" />
11+
<extensions>
12+
<add assembly="NLog.Web.AspNetCore" />
13+
</extensions>
14+
15+
<!-- define various log targets -->
16+
<targets>
17+
<!-- write logs to file -->
18+
<target name="allfile" xsi:type="File" fileName="logs/cap-all-${shortdate}.log"
19+
layout="${myLogLayout}" />
20+
</targets>
21+
22+
<rules>
23+
<!--All logs, including from Microsoft-->
24+
<logger name="*" minlevel="Debug" writeTo="allfile" />
25+
</rules>
26+
</nlog>

0 commit comments

Comments
 (0)