diff --git a/aspnet-core/LINGYUN.MicroService.ApiGateway.sln b/aspnet-core/LINGYUN.MicroService.ApiGateway.sln
index 36c35ba23..68b066655 100644
--- a/aspnet-core/LINGYUN.MicroService.ApiGateway.sln
+++ b/aspnet-core/LINGYUN.MicroService.ApiGateway.sln
@@ -27,6 +27,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LINGYUN.ApiGateway.HttpApi"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LINGYUN.ApiGateway.HttpApi.Client", "modules\apigateway\LINGYUN.ApiGateway.HttpApi.Client\LINGYUN.ApiGateway.HttpApi.Client.csproj", "{4757C7D9-6AE9-477D-9829-55D9906AC3E6}"
EndProject
+Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "common", "common", "{D6629DD3-BA0F-44B5-A97F-3B992ECAB85D}"
+EndProject
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LINGYUN.Abp.EventBus.CAP", "modules\common\LINGYUN.Abp.EventBus.CAP\LINGYUN.Abp.EventBus.CAP.csproj", "{1DA1835B-9EA4-4095-A8CF-10E2778206D3}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -69,6 +73,10 @@ Global
{4757C7D9-6AE9-477D-9829-55D9906AC3E6}.Debug|Any CPU.Build.0 = Debug|Any CPU
{4757C7D9-6AE9-477D-9829-55D9906AC3E6}.Release|Any CPU.ActiveCfg = Release|Any CPU
{4757C7D9-6AE9-477D-9829-55D9906AC3E6}.Release|Any CPU.Build.0 = Release|Any CPU
+ {1DA1835B-9EA4-4095-A8CF-10E2778206D3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {1DA1835B-9EA4-4095-A8CF-10E2778206D3}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {1DA1835B-9EA4-4095-A8CF-10E2778206D3}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {1DA1835B-9EA4-4095-A8CF-10E2778206D3}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@@ -84,6 +92,8 @@ Global
{4D686265-3927-43F5-B9BF-8A013F8BC9E8} = {AD93DD04-989C-40BE-A3F4-25DABF290423}
{D890BEBE-563A-47ED-B767-2E80077B5D37} = {AD93DD04-989C-40BE-A3F4-25DABF290423}
{4757C7D9-6AE9-477D-9829-55D9906AC3E6} = {AD93DD04-989C-40BE-A3F4-25DABF290423}
+ {D6629DD3-BA0F-44B5-A97F-3B992ECAB85D} = {630FB448-8C5C-438F-930D-B0209407DE6A}
+ {1DA1835B-9EA4-4095-A8CF-10E2778206D3} = {D6629DD3-BA0F-44B5-A97F-3B992ECAB85D}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {B327C65A-BD15-480D-825E-9D5A870C521A}
diff --git a/aspnet-core/modules/common/LINGYUN.Abp.EventBus.CAP/DotNetCore/CAP/Processor/AbpCapExpiresMessageCleanupBackgroundWorker.cs b/aspnet-core/modules/common/LINGYUN.Abp.EventBus.CAP/DotNetCore/CAP/Processor/AbpCapExpiresMessageCleanupBackgroundWorker.cs
index 88cfa3e64..2f1f4fdc2 100644
--- a/aspnet-core/modules/common/LINGYUN.Abp.EventBus.CAP/DotNetCore/CAP/Processor/AbpCapExpiresMessageCleanupBackgroundWorker.cs
+++ b/aspnet-core/modules/common/LINGYUN.Abp.EventBus.CAP/DotNetCore/CAP/Processor/AbpCapExpiresMessageCleanupBackgroundWorker.cs
@@ -18,7 +18,7 @@ namespace DotNetCore.CAP.Processor
///
/// 过期消息清理配置
///
- protected MessageCleanupOptions Options { get; }
+ protected AbpCAPEventBusOptions Options { get; }
///
/// Initializer
///
@@ -39,7 +39,7 @@ namespace DotNetCore.CAP.Processor
AbpTimer timer,
IDataStorage storage,
IStorageInitializer initializer,
- IOptions options,
+ IOptions options,
IServiceScopeFactory serviceScopeFactory)
: base(timer, serviceScopeFactory)
{
@@ -47,7 +47,7 @@ namespace DotNetCore.CAP.Processor
Options = options.Value;
Initializer = initializer;
- timer.Period = Options.Interval;
+ timer.Period = Options.CleanUpExpiresMessageInterval;
}
///
@@ -67,7 +67,7 @@ namespace DotNetCore.CAP.Processor
{
Logger.LogDebug($"Collecting expired data from table: {table}");
var time = DateTime.Now;
- await Storage.DeleteExpiresAsync(table, time, Options.ItemBatch);
+ await Storage.DeleteExpiresAsync(table, time, Options.CleanUpExpiresMessageBatch);
}
}
}
diff --git a/aspnet-core/modules/common/LINGYUN.Abp.EventBus.CAP/LINGYUN.Abp.EventBus.CAP.xml b/aspnet-core/modules/common/LINGYUN.Abp.EventBus.CAP/LINGYUN.Abp.EventBus.CAP.xml
index 99d51c538..c27f8e704 100644
--- a/aspnet-core/modules/common/LINGYUN.Abp.EventBus.CAP/LINGYUN.Abp.EventBus.CAP.xml
+++ b/aspnet-core/modules/common/LINGYUN.Abp.EventBus.CAP/LINGYUN.Abp.EventBus.CAP.xml
@@ -59,7 +59,7 @@
Storage
-
+
创建过期消息清理任务
@@ -121,6 +121,28 @@
+
+
+ 过期消息清理配置项
+
+
+
+
+ 发布消息处理失败通知
+
+
+
+
+ 批量清理数量
+ default: 1000
+
+
+
+
+ 执行间隔(ms)
+ default: 3600000 (1 hours)
+
+
AbpECAPExecutionFailedException
@@ -277,23 +299,6 @@
-
-
- 过期消息清理配置项
-
-
-
-
- 批量清理数量
- default: 1000
-
-
-
-
- 执行间隔(ms)
- default: 3600000 (1 hours)
-
-
CAP ServiceCollectionExtensions
diff --git a/aspnet-core/modules/common/LINGYUN.Abp.EventBus.CAP/LINGYUN/Abp/EventBus/CAP/AbpCAPEventBusModule.cs b/aspnet-core/modules/common/LINGYUN.Abp.EventBus.CAP/LINGYUN/Abp/EventBus/CAP/AbpCAPEventBusModule.cs
index d5ee7dae9..ad28b0fe6 100644
--- a/aspnet-core/modules/common/LINGYUN.Abp.EventBus.CAP/LINGYUN/Abp/EventBus/CAP/AbpCAPEventBusModule.cs
+++ b/aspnet-core/modules/common/LINGYUN.Abp.EventBus.CAP/LINGYUN/Abp/EventBus/CAP/AbpCAPEventBusModule.cs
@@ -4,7 +4,6 @@ using Microsoft.Extensions.DependencyInjection;
using Volo.Abp;
using Volo.Abp.BackgroundWorkers;
using Volo.Abp.EventBus;
-using Volo.Abp.ExceptionHandling;
using Volo.Abp.Modularity;
namespace LINGYUN.Abp.EventBus.CAP
@@ -24,22 +23,27 @@ namespace LINGYUN.Abp.EventBus.CAP
public override void ConfigureServices(ServiceConfigurationContext context)
{
var configuration = context.Services.GetConfiguration();
+
+ Configure(configuration.GetSection("CAP:Abp"));
+
+ context.Services.AddTransient();
+
context.Services.AddCAPEventBus(options =>
{
configuration.GetSection("CAP:EventBus").Bind(options);
context.Services.ExecutePreConfiguredActions(options);
- //if (options.FailedThresholdCallback == null)
- //{
- // options.FailedThresholdCallback = async (failed) =>
- // {
- // var exceptionNotifier = failed.ServiceProvider.GetService();
- // if (exceptionNotifier != null)
- // {
- // // TODO: 作为异常处理?
- // await exceptionNotifier.NotifyAsync(new AbpCAPExecutionFailedException(failed.MessageType, failed.Message));
- // }
- // };
- //}
+ if (options.FailedThresholdCallback == null)
+ {
+ options.FailedThresholdCallback = async (failed) =>
+ {
+ var exceptionNotifier = failed.ServiceProvider.GetService();
+ if (exceptionNotifier != null)
+ {
+ // TODO: 作为异常处理?
+ await exceptionNotifier.NotifyAsync(new AbpCAPExecutionFailedException(failed.MessageType, failed.Message));
+ }
+ };
+ }
});
}
diff --git a/aspnet-core/modules/common/LINGYUN.Abp.EventBus.CAP/LINGYUN/Abp/EventBus/CAP/MessageCleanupOptions.cs b/aspnet-core/modules/common/LINGYUN.Abp.EventBus.CAP/LINGYUN/Abp/EventBus/CAP/AbpCAPEventBusOptions.cs
similarity index 50%
rename from aspnet-core/modules/common/LINGYUN.Abp.EventBus.CAP/LINGYUN/Abp/EventBus/CAP/MessageCleanupOptions.cs
rename to aspnet-core/modules/common/LINGYUN.Abp.EventBus.CAP/LINGYUN/Abp/EventBus/CAP/AbpCAPEventBusOptions.cs
index 3f0f13aec..5139b328c 100644
--- a/aspnet-core/modules/common/LINGYUN.Abp.EventBus.CAP/LINGYUN/Abp/EventBus/CAP/MessageCleanupOptions.cs
+++ b/aspnet-core/modules/common/LINGYUN.Abp.EventBus.CAP/LINGYUN/Abp/EventBus/CAP/AbpCAPEventBusOptions.cs
@@ -3,17 +3,21 @@
///
/// 过期消息清理配置项
///
- public class MessageCleanupOptions
+ public class AbpCAPEventBusOptions
{
+ ///
+ /// 发布消息处理失败通知
+ ///
+ public bool NotifyFailedCallback { get; set; } = false;
///
/// 批量清理数量
/// default: 1000
///
- public int ItemBatch { get; set; } = 1000;
+ public int CleanUpExpiresMessageBatch { get; set; } = 1000;
///
/// 执行间隔(ms)
/// default: 3600000 (1 hours)
///
- public int Interval { get; set; } = 3600000;
+ public int CleanUpExpiresMessageInterval { get; set; } = 3600000;
}
}
diff --git a/aspnet-core/modules/common/LINGYUN.Abp.EventBus.CAP/LINGYUN/Abp/EventBus/CAP/FailedThresholdCallbackNotifier.cs b/aspnet-core/modules/common/LINGYUN.Abp.EventBus.CAP/LINGYUN/Abp/EventBus/CAP/FailedThresholdCallbackNotifier.cs
new file mode 100644
index 000000000..eba4e0930
--- /dev/null
+++ b/aspnet-core/modules/common/LINGYUN.Abp.EventBus.CAP/LINGYUN/Abp/EventBus/CAP/FailedThresholdCallbackNotifier.cs
@@ -0,0 +1,31 @@
+using Microsoft.Extensions.Options;
+using System.Threading.Tasks;
+using Volo.Abp.DependencyInjection;
+using Volo.Abp.ExceptionHandling;
+
+namespace LINGYUN.Abp.EventBus.CAP
+{
+ [DisableConventionalRegistration]
+ public class FailedThresholdCallbackNotifier : IFailedThresholdCallbackNotifier
+ {
+ protected AbpCAPEventBusOptions Options { get; }
+ protected IExceptionNotifier ExceptionNotifier { get; }
+
+ public FailedThresholdCallbackNotifier(
+ IOptions options,
+ IExceptionNotifier exceptionNotifier)
+ {
+ Options = options.Value;
+ ExceptionNotifier = exceptionNotifier;
+ }
+
+ public virtual async Task NotifyAsync(AbpCAPExecutionFailedException exception)
+ {
+ // 通过额外的选项来控制是否发送消息处理失败的事件
+ if (Options.NotifyFailedCallback)
+ {
+ await ExceptionNotifier.NotifyAsync(exception);
+ }
+ }
+ }
+}
diff --git a/aspnet-core/modules/common/LINGYUN.Abp.EventBus.CAP/LINGYUN/Abp/EventBus/CAP/IFailedThresholdCallbackNotifier.cs b/aspnet-core/modules/common/LINGYUN.Abp.EventBus.CAP/LINGYUN/Abp/EventBus/CAP/IFailedThresholdCallbackNotifier.cs
new file mode 100644
index 000000000..967f9fdab
--- /dev/null
+++ b/aspnet-core/modules/common/LINGYUN.Abp.EventBus.CAP/LINGYUN/Abp/EventBus/CAP/IFailedThresholdCallbackNotifier.cs
@@ -0,0 +1,9 @@
+using System.Threading.Tasks;
+
+namespace LINGYUN.Abp.EventBus.CAP
+{
+ public interface IFailedThresholdCallbackNotifier
+ {
+ Task NotifyAsync(AbpCAPExecutionFailedException exception);
+ }
+}
diff --git a/aspnet-core/services/apigateway/LINGYUN.ApiGateway.Host/ApiGatewayHostModule.cs b/aspnet-core/services/apigateway/LINGYUN.ApiGateway.Host/ApiGatewayHostModule.cs
index 90a52d709..cf3e45827 100644
--- a/aspnet-core/services/apigateway/LINGYUN.ApiGateway.Host/ApiGatewayHostModule.cs
+++ b/aspnet-core/services/apigateway/LINGYUN.ApiGateway.Host/ApiGatewayHostModule.cs
@@ -3,10 +3,14 @@ using LINGYUN.Abp.EventBus.CAP;
using LINGYUN.ApiGateway.Localization;
using Microsoft.AspNetCore.Authentication.JwtBearer;
using Microsoft.AspNetCore.Builder;
+using Microsoft.AspNetCore.DataProtection;
+using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Routing;
+using Microsoft.AspNetCore.Server.Kestrel.Core;
using Microsoft.Extensions.Caching.StackExchangeRedis;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
+using Microsoft.Extensions.Hosting;
using Ocelot.Configuration.Repository;
using Ocelot.DependencyInjection;
using Ocelot.Extenssions;
@@ -138,12 +142,6 @@ namespace LINGYUN.ApiGateway
.AddVirtualJson("/Localization/Host");
});
- Configure(options =>
- {
- // See https://github.com/abpframework/abp/pull/4564
- options.ConfigureHttpRequestMessage = (requestMessage) => { };
- });
-
var mvcBuilder = context.Services.AddMvc();
mvcBuilder.AddApplicationPart(typeof(ApiGatewayHostModule).Assembly);
@@ -156,6 +154,29 @@ namespace LINGYUN.ApiGateway
});
});
+ if (!hostingEnvironment.IsDevelopment())
+ {
+ // Ssl证书
+ var sslOptions = configuration.GetSection("App:SslOptions");
+ if (sslOptions.Exists())
+ {
+ var fileName = sslOptions["FileName"];
+ var password = sslOptions["Password"];
+ Configure(options =>
+ {
+ options.ConfigureEndpointDefaults(cfg =>
+ {
+ cfg.UseHttps(fileName, password);
+ });
+ });
+ }
+
+ var redis = ConnectionMultiplexer.Connect(configuration["Redis:Configuration"]);
+ context.Services
+ .AddDataProtection()
+ .PersistKeysToStackExchangeRedis(redis, "ApiGatewayHost-Protection-Keys");
+ }
+
context.Services
.AddOcelot()
.AddPolly()
diff --git a/aspnet-core/services/apigateway/LINGYUN.ApiGateway.Host/LINGYUN.ApiGateway.Host.csproj b/aspnet-core/services/apigateway/LINGYUN.ApiGateway.Host/LINGYUN.ApiGateway.Host.csproj
index 12648e1f9..6336bae4d 100644
--- a/aspnet-core/services/apigateway/LINGYUN.ApiGateway.Host/LINGYUN.ApiGateway.Host.csproj
+++ b/aspnet-core/services/apigateway/LINGYUN.ApiGateway.Host/LINGYUN.ApiGateway.Host.csproj
@@ -14,6 +14,7 @@
+
diff --git a/aspnet-core/services/apigateway/LINGYUN.ApiGateway.HttpApi.Host/ApiGatewayHttpApiHostModule.cs b/aspnet-core/services/apigateway/LINGYUN.ApiGateway.HttpApi.Host/ApiGatewayHttpApiHostModule.cs
index dc2992118..21f2e7eba 100644
--- a/aspnet-core/services/apigateway/LINGYUN.ApiGateway.HttpApi.Host/ApiGatewayHttpApiHostModule.cs
+++ b/aspnet-core/services/apigateway/LINGYUN.ApiGateway.HttpApi.Host/ApiGatewayHttpApiHostModule.cs
@@ -188,7 +188,7 @@ namespace LINGYUN.ApiGateway
var redis = ConnectionMultiplexer.Connect(configuration["Redis:Configuration"]);
context.Services
.AddDataProtection()
- .PersistKeysToStackExchangeRedis(redis, "ApiGateway-Protection-Keys");
+ .PersistKeysToStackExchangeRedis(redis, "ApiGatewayAdmin-Protection-Keys");
}
Configure(options =>