Skip to content

Commit

Permalink
release 2.4.2 (#272)
Browse files Browse the repository at this point in the history
* update version to 2.4.0

* Add version options to config file.

* update resource

* add  message version support  for dashboard

* add  message version support  for dashboard

* Support using version to isolate messages. #220

* update mongo unit tests

* update unit tests

* update unit tests

* Set default versions for consumer groups

* solve the problem of issue#181 (#237)

* Issue#235 (#238)

* solve the problem of issue#181

* solve the problem of issue#235

* refactor

* Fix the message persistence bug. #240

* using new CamelCaseNamingStrategy

* update packages to .net core 2.2

* update test framework to netcoreapp2.2

* Update .travis.yml

* update TargetFramework

* Exclude build samples project

* update version to 2.4.1

* add samples project to sln for build

* update version to 2.4.2

* Fixed PostgreSql version isolation feature bug. (#256)

* Fixed spelling errors

* modify cap publish Message to rabbitmq slow (#261)

* Startup the CAP with the BackgroundService.  #265

* update samples

* Fixed SQL query bug. #266

* update travis ci config

* update travis ci config

* adjust dashboard table column width

* adjust the consumer execution time to milliseconds
  • Loading branch information
yang-xiaodong authored Jan 8, 2019
1 parent 94e54c2 commit fb6943e
Show file tree
Hide file tree
Showing 21 changed files with 81 additions and 101 deletions.
21 changes: 11 additions & 10 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,21 +1,22 @@
language: csharp
sudo: required
dist: trusty
dist: xenial
solution: CAP.sln
dotnet: 2.2.100
dotnet: 2.2
mono: none

matrix:
include:
- os: linux
dist: trusty # Ubuntu 14.04
sudo: required
- os: osx
osx_image: xcode8.3 # macOS 10.12
#matrix:
# include:
# - dotnet: 2.2
# - os: linux
# dist: trusty # Ubuntu 14.04
# sudo: required
# - os: osx
# osx_image: xcode8.3 # macOS 10.12

# Run the build script
script:
- dotnet --info
- dotnet restore CAP.sln
- dotnet build CAP.sln
- dotnet test test/DotNetCore.CAP.Test/DotNetCore.CAP.Test.csproj
- dotnet test test/DotNetCore.CAP.Test/DotNetCore.CAP.Test.csproj
2 changes: 1 addition & 1 deletion build/version.props
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<PropertyGroup>
<VersionMajor>2</VersionMajor>
<VersionMinor>4</VersionMinor>
<VersionPatch>1</VersionPatch>
<VersionPatch>2</VersionPatch>
<VersionQuality></VersionQuality>
<VersionPrefix>$(VersionMajor).$(VersionMinor).$(VersionPatch)</VersionPrefix>
</PropertyGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public ValuesController(IMongoClient client, ICapPublisher capBus)
[Route("~/without/transaction")]
public IActionResult WithoutTransaction()
{
_capBus.Publish("sample.rabbitmq.mongodb", DateTime.Now);
_capBus.PublishAsync("sample.rabbitmq.mongodb", DateTime.Now);

return Ok();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

<PropertyGroup>
<TargetFramework>netcoreapp2.2</TargetFramework>
<LangVersion>7.1</LangVersion>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.App" />
Expand Down
11 changes: 6 additions & 5 deletions samples/Sample.RabbitMQ.MongoDB/Startup.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Microsoft.AspNetCore.Builder;
using System;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Configuration;
Expand All @@ -18,14 +19,14 @@ public Startup(IConfiguration configuration)

public void ConfigureServices(IServiceCollection services)
{
services.AddSingleton<IMongoClient>(new MongoClient("mongodb://192.168.10.110:27017,192.168.10.110:27018,192.168.10.110:27019/?replicaSet=rs0"));
services.AddSingleton<IMongoClient>(new MongoClient(Configuration.GetConnectionString("MongoDB")));
services.AddCap(x =>
{
x.UseMongoDB("mongodb://192.168.10.110:27017,192.168.10.110:27018,192.168.10.110:27019/?replicaSet=rs0");
x.UseRabbitMQ("localhost");
x.UseMongoDB(Configuration.GetConnectionString("MongoDB"));
x.UseRabbitMQ("192.168.2.120");
x.UseDashboard();
});
services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1);
services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2);
}

public void Configure(IApplicationBuilder app, IHostingEnvironment env)
Expand Down
6 changes: 3 additions & 3 deletions samples/Sample.RabbitMQ.MongoDB/appsettings.json
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
{
"Logging": {
"LogLevel": {
"Default": "Warning"
"Default": "Debug"
}
},
"AllowedHosts": "*",
"ConnectionStrings": {
"MongoDB": "mongodb://localhost:27017,localhost:27018,localhost:27019/?replicaSet=rs0"
"MongoDB": "mongodb://192.168.2.120:27017,192.168.2.120:27018,192.168.2.120:27019/?replicaSet=rs0"
},
"RabbitMQ": {
"HostName": "localhost",
"Port": 5672,
"UserName": "",
"Password": ""
}
}
}
2 changes: 1 addition & 1 deletion src/DotNetCore.CAP.MySql/IMonitoringApi.MySql.cs
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public IList<MessageDto> Messages(MessageQueryDto queryDto)

if (!string.IsNullOrEmpty(queryDto.Group))
{
where += " and Group=@Group";
where += " and `Group`=@Group";
}

if (!string.IsNullOrEmpty(queryDto.Content))
Expand Down
2 changes: 1 addition & 1 deletion src/DotNetCore.CAP.PostgreSql/ICapPublisher.PostgreSql.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ protected override async Task ExecuteAsync(CapPublishedMessage message, ICapTran
private string PrepareSql()
{
return
$"INSERT INTO \"{_options.Schema}\".\"published\" (\"Id\",\"Version\",\"Name\",\"Content\",\"Retries\",\"Added\",\"ExpiresAt\",\"StatusName\")VALUES(@Id,@Version,@Name,@Content,@Retries,@Added,@ExpiresAt,@StatusName);";
$"INSERT INTO \"{_options.Schema}\".\"published\" (\"Id\",\"Version\",\"Name\",\"Content\",\"Retries\",\"Added\",\"ExpiresAt\",\"StatusName\")VALUES(@Id,'{_options.Version}',@Name,@Content,@Retries,@Added,@ExpiresAt,@StatusName);";
}

private IDbConnection InitDbConnection()
Expand Down
2 changes: 1 addition & 1 deletion src/DotNetCore.CAP.SqlServer/IMonitoringApi.SqlServer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public IList<MessageDto> Messages(MessageQueryDto queryDto)

if (!string.IsNullOrEmpty(queryDto.Group))
{
where += " and group=@Group";
where += " and [group]=@Group";
}

if (!string.IsNullOrEmpty(queryDto.Content))
Expand Down
9 changes: 3 additions & 6 deletions src/DotNetCore.CAP/CAP.AppBuilderExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ internal static class AppBuilderExtensions
/// </summary>
/// <param name="app">The <see cref="IApplicationBuilder" /> instance this method extends.</param>
/// <returns>The <see cref="IApplicationBuilder" /> instance this method extends.</returns>
public static IApplicationBuilder UseCap(this IApplicationBuilder app)
public static IApplicationBuilder UseCapDashboard(this IApplicationBuilder app)
{
if (app == null)
{
Expand All @@ -30,10 +30,7 @@ public static IApplicationBuilder UseCap(this IApplicationBuilder app)
CheckRequirement(app);

var provider = app.ApplicationServices;

var bootstrapper = provider.GetRequiredService<IBootstrapper>();
bootstrapper.BootstrapAsync();


if (provider.GetService<DashboardOptions>() != null)
{
if (provider.GetService<DiscoveryOptions>() != null)
Expand Down Expand Up @@ -78,7 +75,7 @@ public Action<IApplicationBuilder> Configure(Action<IApplicationBuilder> next)
{
return app =>
{
app.UseCap();
app.UseCapDashboard();

next(app);
};
Expand Down
5 changes: 3 additions & 2 deletions src/DotNetCore.CAP/CAP.ServiceCollectionExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.DependencyInjection.Extensions;
using Microsoft.Extensions.Hosting;

// ReSharper disable once CheckNamespace
namespace Microsoft.Extensions.DependencyInjection
Expand Down Expand Up @@ -48,10 +49,9 @@ public static CapBuilder AddCap(this IServiceCollection services, Action<CapOpti
services.TryAddSingleton<IConsumerInvokerFactory, ConsumerInvokerFactory>();
services.TryAddSingleton<MethodMatcherCache>();

//Bootstrapper and Processors
//Processors
services.TryAddEnumerable(ServiceDescriptor.Singleton<IProcessingServer, ConsumerHandler>());
services.TryAddEnumerable(ServiceDescriptor.Singleton<IProcessingServer, CapProcessingServer>());
services.TryAddSingleton<IBootstrapper, DefaultBootstrapper>();
services.TryAddSingleton<IStateChanger, StateChanger>();

//Queue's message processor
Expand All @@ -72,6 +72,7 @@ public static CapBuilder AddCap(this IServiceCollection services, Action<CapOpti
services.AddSingleton(options);

//Startup and Middleware
services.AddTransient<IHostedService, DefaultBootstrapper>();
services.AddTransient<IStartupFilter, CapStartupFilter>();

return new CapBuilder(services);
Expand Down
2 changes: 1 addition & 1 deletion src/DotNetCore.CAP/Dashboard/Pages/PublishedPage.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@
<table class="table">
<thead>
<tr>
<th style="width: 60px;">
<th style="width: 30px;">
<input type="checkbox" class="js-jobs-list-select-all"/>
</th>
<th>@Strings.Common_Id</th>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ protected override void Execute()
<table class=""table"">
<thead>
<tr>
<th style=""width:60px;"">
<th style=""width:30px;"">
<input type=""checkbox"" class=""js-jobs-list-select-all"" />
</th>
<th style=""width:22%;"">");
Expand Down
2 changes: 1 addition & 1 deletion src/DotNetCore.CAP/Dashboard/Pages/ReceivedPage.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@
<table class="table">
<thead>
<tr>
<th style="width: 60px;">
<th style="width: 30px;">
<input type="checkbox" class="js-jobs-list-select-all"/>
</th>
<th>@Strings.Common_Id</th>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ protected override void Execute()
<table class=""table"">
<thead>
<tr>
<th style=""width:60px;"">
<th style=""width:30px;"">
<input type=""checkbox"" class=""js-jobs-list-select-all"" />
</th>
<th>");
Expand Down
69 changes: 22 additions & 47 deletions src/DotNetCore.CAP/IBootstrapper.Default.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,89 +5,59 @@
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;

namespace DotNetCore.CAP
{
/// <inheritdoc />
/// <summary>
/// Default implement of <see cref="T:DotNetCore.CAP.IBootstrapper" />.
/// </summary>
internal class DefaultBootstrapper : IBootstrapper
internal class DefaultBootstrapper : BackgroundService, IBootstrapper
{
private readonly IApplicationLifetime _appLifetime;
private readonly CancellationTokenSource _cts;
private readonly CancellationTokenRegistration _ctsRegistration;
private readonly ILogger<DefaultBootstrapper> _logger;
private Task _bootstrappingTask;

public DefaultBootstrapper(
ILogger<DefaultBootstrapper> logger,
IStorage storage,
IApplicationLifetime appLifetime,
IEnumerable<IProcessingServer> processors)
{
_logger = logger;
_appLifetime = appLifetime;
Storage = storage;
Processors = processors;

_cts = new CancellationTokenSource();
_ctsRegistration = appLifetime.ApplicationStopping.Register(() =>
{
_cts.Cancel();
try
{
_bootstrappingTask?.GetAwaiter().GetResult();
}
catch (OperationCanceledException ex)
{
_logger.ExpectedOperationCanceledException(ex);
}
});
}

private IStorage Storage { get; }

private IEnumerable<IProcessingServer> Processors { get; }

public Task BootstrapAsync()
{
return _bootstrappingTask = BootstrapTaskAsync();
}

private async Task BootstrapTaskAsync()
public async Task BootstrapAsync(CancellationToken stoppingToken)
{
_logger.LogInformation("### CAP starting...");
_logger.LogDebug("### CAP background task is starting.");

await Storage.InitializeAsync(_cts.Token);
await Storage.InitializeAsync(stoppingToken);

if (_cts.IsCancellationRequested)
stoppingToken.Register(() =>
{
return;
}
_logger.LogDebug("### CAP background task is stopping.");

_appLifetime.ApplicationStopping.Register(() =>
{
foreach (var item in Processors)
{
item.Dispose();
try
{
item.Dispose();
}
catch (OperationCanceledException ex)
{
_logger.ExpectedOperationCanceledException(ex);
}
}
});

if (_cts.IsCancellationRequested)
{
return;
}


await BootstrapCoreAsync();

_ctsRegistration.Dispose();
_cts.Dispose();

_logger.LogInformation("### CAP started!");
}
}

protected virtual Task BootstrapCoreAsync()
{
Expand All @@ -105,5 +75,10 @@ protected virtual Task BootstrapCoreAsync()

return Task.CompletedTask;
}

protected override async Task ExecuteAsync(CancellationToken stoppingToken)
{
await BootstrapAsync(stoppingToken);
}
}
}
3 changes: 2 additions & 1 deletion src/DotNetCore.CAP/IBootstrapper.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// Copyright (c) .NET Core Community. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.

using System.Threading;
using System.Threading.Tasks;

namespace DotNetCore.CAP
Expand All @@ -10,6 +11,6 @@ namespace DotNetCore.CAP
/// </summary>
public interface IBootstrapper
{
Task BootstrapAsync();
Task BootstrapAsync(CancellationToken stoppingToken);
}
}
25 changes: 14 additions & 11 deletions src/DotNetCore.CAP/IPublishMessageSender.Base.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,20 +44,23 @@ protected BasePublishMessageSender(

public async Task<OperateResult> SendAsync(CapPublishedMessage message)
{
bool retry;
OperateResult result;
do
return await Task.Run(async () =>
{
var executedResult = await SendWithoutRetryAsync(message);
result = executedResult.Item2;
if (result == OperateResult.Success)
bool retry;
OperateResult result;
do
{
return result;
}
retry = executedResult.Item1;
} while (retry);
var executedResult = await SendWithoutRetryAsync(message);
result = executedResult.Item2;
if (result == OperateResult.Success)
{
return result;
}
retry = executedResult.Item1;
} while (retry);

return result;
return result;
});
}

private async Task<(bool, OperateResult)> SendWithoutRetryAsync(CapPublishedMessage message)
Expand Down
Loading

0 comments on commit fb6943e

Please sign in to comment.