Browse Source

Release version 2.1.4 (#97)

* Fixed the connection bug of getting message from table. #83

* update version to 2.1.4

* remove `TableNamePrefix` option from `MySqlOptions` to `EFOptions`.  #84

* fixed entityframework rename table name prefix bug.  #84

* fixed sql server scripts bug of create table scheme. #85

* fixed entityframework rename table name prefix bug. #84

* modify error message of logger write

* Fixed bug of the FailedRetryCount does not increase when raised SubscriberNotFoundException. #90

* Fixed thread safety issue about KafkaOptions. #89

* upgrade nuget package
master
Savorboard 6 years ago
committed by GitHub
parent
commit
e557542721
20 changed files with 81 additions and 43 deletions
  1. +1
    -1
      build/version.props
  2. +9
    -7
      src/DotNetCore.CAP.Kafka/KafkaConsumerClient.cs
  3. +7
    -0
      src/DotNetCore.CAP.MySql/CAP.EFOptions.cs
  4. +11
    -1
      src/DotNetCore.CAP.MySql/CAP.MySqlCapOptionsExtension.cs
  5. +0
    -3
      src/DotNetCore.CAP.MySql/CAP.MySqlOptions.cs
  6. +7
    -5
      src/DotNetCore.CAP.MySql/CAP.Options.Extensions.cs
  7. +1
    -1
      src/DotNetCore.CAP.MySql/DotNetCore.CAP.MySql.csproj
  8. +2
    -0
      src/DotNetCore.CAP.MySql/MySqlStorageConnection.cs
  9. +6
    -5
      src/DotNetCore.CAP.PostgreSql/CAP.Options.Extensions.cs
  10. +9
    -0
      src/DotNetCore.CAP.PostgreSql/CAP.PostgreSqlCapOptionsExtension.cs
  11. +1
    -1
      src/DotNetCore.CAP.PostgreSql/DotNetCore.CAP.PostgreSql.csproj
  12. +6
    -5
      src/DotNetCore.CAP.SqlServer/CAP.Options.Extensions.cs
  13. +6
    -1
      src/DotNetCore.CAP.SqlServer/CAP.SqlServerCapOptionsExtension.cs
  14. +1
    -1
      src/DotNetCore.CAP.SqlServer/SqlServerStorage.cs
  15. +2
    -2
      src/DotNetCore.CAP/DotNetCore.CAP.csproj
  16. +3
    -1
      src/DotNetCore.CAP/IQueueExecutor.Subscribe.cs
  17. +3
    -3
      test/DotNetCore.CAP.MySql.Test/DotNetCore.CAP.MySql.Test.csproj
  18. +2
    -2
      test/DotNetCore.CAP.PostgreSql.Test/DotNetCore.CAP.PostgreSql.Test.csproj
  19. +2
    -2
      test/DotNetCore.CAP.SqlServer.Test/DotNetCore.CAP.SqlServer.Test.csproj
  20. +2
    -2
      test/DotNetCore.CAP.Test/DotNetCore.CAP.Test.csproj

+ 1
- 1
build/version.props View File

@@ -2,7 +2,7 @@
<PropertyGroup>
<VersionMajor>2</VersionMajor>
<VersionMinor>1</VersionMinor>
<VersionPatch>3</VersionPatch>
<VersionPatch>4</VersionPatch>
<VersionQuality></VersionQuality>
<VersionPrefix>$(VersionMajor).$(VersionMinor).$(VersionPatch)</VersionPrefix>
</PropertyGroup>


+ 9
- 7
src/DotNetCore.CAP.Kafka/KafkaConsumerClient.cs View File

@@ -66,16 +66,18 @@ namespace DotNetCore.CAP.Kafka

private void InitKafkaClient()
{
_kafkaOptions.MainConfig["group.id"] = _groupId;
lock (_kafkaOptions)
{
_kafkaOptions.MainConfig["group.id"] = _groupId;

var config = _kafkaOptions.AsKafkaConfig();
_consumerClient = new Consumer<Null, string>(config, null, StringDeserializer);
_consumerClient.OnConsumeError += ConsumerClient_OnConsumeError;
_consumerClient.OnMessage += ConsumerClient_OnMessage;
_consumerClient.OnError += ConsumerClient_OnError;
var config = _kafkaOptions.AsKafkaConfig();
_consumerClient = new Consumer<Null, string>(config, null, StringDeserializer);
_consumerClient.OnConsumeError += ConsumerClient_OnConsumeError;
_consumerClient.OnMessage += ConsumerClient_OnMessage;
_consumerClient.OnError += ConsumerClient_OnError;
}
}


private void ConsumerClient_OnConsumeError(object sender, Message e)
{
var message = e.Deserialize<Null, string>(null, StringDeserializer);


+ 7
- 0
src/DotNetCore.CAP.MySql/CAP.EFOptions.cs View File

@@ -5,6 +5,13 @@ namespace DotNetCore.CAP
{
public class EFOptions
{
public const string DefaultSchema = "cap";

/// <summary>
/// Gets or sets the table name prefix to use when creating database objects.
/// </summary>
public string TableNamePrefix { get; set; } = DefaultSchema;

/// <summary>
/// EF db context type.
/// </summary>


+ 11
- 1
src/DotNetCore.CAP.MySql/CAP.MySqlCapOptionsExtension.cs View File

@@ -25,22 +25,32 @@ namespace DotNetCore.CAP
services.AddScoped<ICallbackPublisher, CapPublisher>();
services.AddTransient<IAdditionalProcessor, DefaultAdditionalProcessor>();

AddSingletionMySqlOptions(services);
}

private void AddSingletionMySqlOptions(IServiceCollection services)
{
var mysqlOptions = new MySqlOptions();

_configure(mysqlOptions);

if (mysqlOptions.DbContextType != null)
{
services.AddSingleton(x =>
{
using (var scope = x.CreateScope())
{
var provider = scope.ServiceProvider;
var dbContext = (DbContext) provider.GetService(mysqlOptions.DbContextType);
var dbContext = (DbContext)provider.GetService(mysqlOptions.DbContextType);
mysqlOptions.ConnectionString = dbContext.Database.GetDbConnection().ConnectionString;
return mysqlOptions;
}
});
}
else
{
services.AddSingleton(mysqlOptions);
}
}
}
}

+ 0
- 3
src/DotNetCore.CAP.MySql/CAP.MySqlOptions.cs View File

@@ -1,5 +1,4 @@
// ReSharper disable once CheckNamespace

namespace DotNetCore.CAP
{
public class MySqlOptions : EFOptions
@@ -8,7 +7,5 @@ namespace DotNetCore.CAP
/// Gets or sets the database's connection string that will be used to store database entities.
/// </summary>
public string ConnectionString { get; set; }

public string TableNamePrefix { get; set; } = "cap";
}
}

+ 7
- 5
src/DotNetCore.CAP.MySql/CAP.Options.Extensions.cs View File

@@ -16,6 +16,7 @@ namespace Microsoft.Extensions.DependencyInjection
{
if (configure == null) throw new ArgumentNullException(nameof(configure));


options.RegisterExtension(new MySqlCapOptionsExtension(configure));

return options;
@@ -24,7 +25,7 @@ namespace Microsoft.Extensions.DependencyInjection
public static CapOptions UseEntityFramework<TContext>(this CapOptions options)
where TContext : DbContext
{
return options.UseEntityFramework<TContext>(opt => { opt.DbContextType = typeof(TContext); });
return options.UseEntityFramework<TContext>(opt => { });
}

public static CapOptions UseEntityFramework<TContext>(this CapOptions options, Action<EFOptions> configure)
@@ -32,10 +33,11 @@ namespace Microsoft.Extensions.DependencyInjection
{
if (configure == null) throw new ArgumentNullException(nameof(configure));

var efOptions = new EFOptions {DbContextType = typeof(TContext)};
configure(efOptions);

options.RegisterExtension(new MySqlCapOptionsExtension(configure));
options.RegisterExtension(new MySqlCapOptionsExtension(x =>
{
configure(x);
x.DbContextType = typeof(TContext);
}));

return options;
}


+ 1
- 1
src/DotNetCore.CAP.MySql/DotNetCore.CAP.MySql.csproj View File

@@ -17,7 +17,7 @@
<PackageReference Include="Dapper" Version="1.50.4" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="2.0.1" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="2.0.1" />
<PackageReference Include="MySqlConnector" Version="0.34.2" />
<PackageReference Include="MySqlConnector" Version="0.36.0" />
</ItemGroup>

<ItemGroup>


+ 2
- 0
src/DotNetCore.CAP.MySql/MySqlStorageConnection.cs View File

@@ -57,6 +57,7 @@ SELECT * FROM `{_prefix}.published` WHERE Id=LAST_INSERT_ID();";

using (var connection = new MySqlConnection(Options.ConnectionString))
{
connection.Open();
connection.Execute("SELECT LAST_INSERT_ID(0)");
return await connection.QueryFirstOrDefaultAsync<CapPublishedMessage>(sql);
}
@@ -103,6 +104,7 @@ SELECT * FROM `{_prefix}.received` WHERE Id=LAST_INSERT_ID();";

using (var connection = new MySqlConnection(Options.ConnectionString))
{
connection.Open();
connection.Execute("SELECT LAST_INSERT_ID(0)");
return await connection.QueryFirstOrDefaultAsync<CapReceivedMessage>(sql);
}


+ 6
- 5
src/DotNetCore.CAP.PostgreSql/CAP.Options.Extensions.cs View File

@@ -24,7 +24,7 @@ namespace Microsoft.Extensions.DependencyInjection
public static CapOptions UseEntityFramework<TContext>(this CapOptions options)
where TContext : DbContext
{
return options.UseEntityFramework<TContext>(opt => { opt.DbContextType = typeof(TContext); });
return options.UseEntityFramework<TContext>(opt => { });
}

public static CapOptions UseEntityFramework<TContext>(this CapOptions options, Action<EFOptions> configure)
@@ -32,10 +32,11 @@ namespace Microsoft.Extensions.DependencyInjection
{
if (configure == null) throw new ArgumentNullException(nameof(configure));

var efOptions = new EFOptions {DbContextType = typeof(TContext)};
configure(efOptions);

options.RegisterExtension(new PostgreSqlCapOptionsExtension(configure));
options.RegisterExtension(new PostgreSqlCapOptionsExtension(x =>
{
configure(x);
x.DbContextType = typeof(TContext);
}));

return options;
}


+ 9
- 0
src/DotNetCore.CAP.PostgreSql/CAP.PostgreSqlCapOptionsExtension.cs View File

@@ -25,10 +25,16 @@ namespace DotNetCore.CAP
services.AddScoped<ICallbackPublisher, CapPublisher>();
services.AddTransient<IAdditionalProcessor, DefaultAdditionalProcessor>();

AddSingletonPostgreSqlOptions(services);
}

private void AddSingletonPostgreSqlOptions(IServiceCollection services)
{
var postgreSqlOptions = new PostgreSqlOptions();
_configure(postgreSqlOptions);

if (postgreSqlOptions.DbContextType != null)
{
services.AddSingleton(x =>
{
using (var scope = x.CreateScope())
@@ -39,8 +45,11 @@ namespace DotNetCore.CAP
return postgreSqlOptions;
}
});
}
else
{
services.AddSingleton(postgreSqlOptions);
}
}
}
}

+ 1
- 1
src/DotNetCore.CAP.PostgreSql/DotNetCore.CAP.PostgreSql.csproj View File

@@ -17,7 +17,7 @@
<PackageReference Include="Dapper" Version="1.50.4" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="2.0.1" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="2.0.1" />
<PackageReference Include="Npgsql" Version="3.2.6" />
<PackageReference Include="Npgsql" Version="3.2.7" />
</ItemGroup>

<ItemGroup>


+ 6
- 5
src/DotNetCore.CAP.SqlServer/CAP.Options.Extensions.cs View File

@@ -24,7 +24,7 @@ namespace Microsoft.Extensions.DependencyInjection
public static CapOptions UseEntityFramework<TContext>(this CapOptions options)
where TContext : DbContext
{
return options.UseEntityFramework<TContext>(opt => { opt.DbContextType = typeof(TContext); });
return options.UseEntityFramework<TContext>(opt => { });
}

public static CapOptions UseEntityFramework<TContext>(this CapOptions options, Action<EFOptions> configure)
@@ -32,10 +32,11 @@ namespace Microsoft.Extensions.DependencyInjection
{
if (configure == null) throw new ArgumentNullException(nameof(configure));

var efOptions = new EFOptions {DbContextType = typeof(TContext)};
configure(efOptions);

options.RegisterExtension(new SqlServerCapOptionsExtension(configure));
options.RegisterExtension(new SqlServerCapOptionsExtension(x =>
{
configure(x);
x.DbContextType = typeof(TContext);
}));

return options;
}


+ 6
- 1
src/DotNetCore.CAP.SqlServer/CAP.SqlServerCapOptionsExtension.cs View File

@@ -24,6 +24,7 @@ namespace DotNetCore.CAP
services.AddScoped<ICapPublisher, CapPublisher>();
services.AddScoped<ICallbackPublisher, CapPublisher>();
services.AddTransient<IAdditionalProcessor, DefaultAdditionalProcessor>();

AddSqlServerOptions(services);
}

@@ -34,18 +35,22 @@ namespace DotNetCore.CAP
_configure(sqlServerOptions);

if (sqlServerOptions.DbContextType != null)
{
services.AddSingleton(x =>
{
using (var scope = x.CreateScope())
{
var provider = scope.ServiceProvider;
var dbContext = (DbContext) provider.GetService(sqlServerOptions.DbContextType);
var dbContext = (DbContext)provider.GetService(sqlServerOptions.DbContextType);
sqlServerOptions.ConnectionString = dbContext.Database.GetDbConnection().ConnectionString;
return sqlServerOptions;
}
});
}
else
{
services.AddSingleton(sqlServerOptions);
}
}
}
}

+ 1
- 1
src/DotNetCore.CAP.SqlServer/SqlServerStorage.cs View File

@@ -54,7 +54,7 @@ namespace DotNetCore.CAP.SqlServer
$@"
IF NOT EXISTS (SELECT * FROM sys.schemas WHERE name = '{schema}')
BEGIN
EXEC('CREATE SCHEMA {schema}')
EXEC('CREATE SCHEMA [{schema}]')
END;

IF OBJECT_ID(N'[{schema}].[Queue]',N'U') IS NULL


+ 2
- 2
src/DotNetCore.CAP/DotNetCore.CAP.csproj View File

@@ -48,12 +48,12 @@
<EmbeddedResource Include="Dashboard\Content\js\rickshaw.min.js" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Consul" Version="0.7.2.3" />
<PackageReference Include="Consul" Version="0.7.2.4" />
<PackageReference Include="Microsoft.AspNetCore.Hosting.Abstractions" Version="2.0.1" />
<PackageReference Include="Microsoft.AspNetCore.Http.Abstractions" Version="2.0.1" />
<PackageReference Include="Microsoft.Extensions.Options" Version="2.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="2.0.0" />
<PackageReference Include="Newtonsoft.Json" Version="10.0.3" />
<PackageReference Include="Newtonsoft.Json" Version="11.0.1" />
<PackageReference Include="System.Data.Common" Version="4.3.0" />
<PackageReference Include="System.Threading.ThreadPool" Version="4.3.0" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="2.0.0" />


+ 3
- 1
src/DotNetCore.CAP/IQueueExecutor.Subscribe.cs View File

@@ -36,7 +36,7 @@ namespace DotNetCore.CAP

if (message == null)
{
_logger.LogError($"Can not find mesage at cap received message table, message id:{fetched.MessageId} !!!");
_logger.LogError($"Can not found the `message` at cap received message table, message id:{fetched.MessageId} !!!");
return OperateResult.Failed();
}

@@ -68,6 +68,8 @@ namespace DotNetCore.CAP

AddErrorReasonToContent(message, ex);

++message.Retries; //issue: https://github.com/dotnetcore/CAP/issues/90

await _stateChanger.ChangeStateAsync(message, new FailedState(), connection);

fetched.RemoveFromQueue();


+ 3
- 3
test/DotNetCore.CAP.MySql.Test/DotNetCore.CAP.MySql.Test.csproj View File

@@ -15,13 +15,13 @@
<ItemGroup>
<PackageReference Include="Dapper" Version="1.50.4" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.5.0" />
<PackageReference Include="MySqlConnector" Version="0.34.2" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.6.0" />
<PackageReference Include="MySqlConnector" Version="0.36.0" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.3.1" />
<PackageReference Include="xunit" Version="2.3.1" />
<PackageReference Include="Microsoft.AspNetCore.Http" Version="2.0.1" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="2.0.0" />
<PackageReference Include="Moq" Version="4.8.1" />
<PackageReference Include="Moq" Version="4.8.2" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="2.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="2.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration" Version="2.0.0" />


+ 2
- 2
test/DotNetCore.CAP.PostgreSql.Test/DotNetCore.CAP.PostgreSql.Test.csproj View File

@@ -8,8 +8,8 @@

<ItemGroup>
<PackageReference Include="Dapper" Version="1.50.4" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.5.0" />
<PackageReference Include="Npgsql" Version="3.2.6" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.6.0" />
<PackageReference Include="Npgsql" Version="3.2.7" />
<PackageReference Include="xunit" Version="2.3.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.3.1" />
</ItemGroup>


+ 2
- 2
test/DotNetCore.CAP.SqlServer.Test/DotNetCore.CAP.SqlServer.Test.csproj View File

@@ -12,13 +12,13 @@

<ItemGroup>
<PackageReference Include="Dapper" Version="1.50.4" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.5.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.6.0" />
<PackageReference Include="System.Data.SqlClient" Version="4.4.2" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.3.1" />
<PackageReference Include="xunit" Version="2.3.1" />
<PackageReference Include="Microsoft.AspNetCore.Http" Version="2.0.1" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="2.0.0" />
<PackageReference Include="Moq" Version="4.8.1" />
<PackageReference Include="Moq" Version="4.8.2" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="2.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="2.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration" Version="2.0.0" />


+ 2
- 2
test/DotNetCore.CAP.Test/DotNetCore.CAP.Test.csproj View File

@@ -8,13 +8,13 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.5.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.6.0" />
<PackageReference Include="System.Data.Common" Version="4.3.0" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.3.1" />
<PackageReference Include="xunit" Version="2.3.1" />
<PackageReference Include="Microsoft.AspNetCore.Http" Version="2.0.1" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="2.0.0" />
<PackageReference Include="Moq" Version="4.8.1" />
<PackageReference Include="Moq" Version="4.8.2" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="2.0.0" />
</ItemGroup>



Loading…
Cancel
Save