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 5e60c1842..bfa18c163 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
@@ -121,6 +121,45 @@
+
+
+ AbpECAPExecutionFailedException
+
+
+
+
+ MessageType
+
+
+
+
+ Message
+
+
+
+
+ constructor
+
+
+
+
+
+
+ constructor
+
+
+
+
+
+
+
+ constructor
+
+
+
+
+
+
CAP分布式事件总线
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 82d8c8412..d5ee7dae9 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,6 +4,7 @@ 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
@@ -27,6 +28,18 @@ namespace LINGYUN.Abp.EventBus.CAP
{
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));
+ // }
+ // };
+ //}
});
}
diff --git a/aspnet-core/modules/common/LINGYUN.Abp.EventBus.CAP/LINGYUN/Abp/EventBus/CAP/AbpCAPExecutionFailedException.cs b/aspnet-core/modules/common/LINGYUN.Abp.EventBus.CAP/LINGYUN/Abp/EventBus/CAP/AbpCAPExecutionFailedException.cs
new file mode 100644
index 000000000..f8931ceda
--- /dev/null
+++ b/aspnet-core/modules/common/LINGYUN.Abp.EventBus.CAP/LINGYUN/Abp/EventBus/CAP/AbpCAPExecutionFailedException.cs
@@ -0,0 +1,56 @@
+using DotNetCore.CAP.Messages;
+using System;
+using Volo.Abp;
+
+namespace LINGYUN.Abp.EventBus.CAP
+{
+ ///
+ /// AbpECAPExecutionFailedException
+ ///
+ public class AbpCAPExecutionFailedException : AbpException
+ {
+ ///
+ /// MessageType
+ ///
+ public MessageType MessageType { get; set; }
+ ///
+ /// Message
+ ///
+ public Message Origin { get; set; }
+ ///
+ /// constructor
+ ///
+ ///
+ ///
+ public AbpCAPExecutionFailedException(MessageType messageType, Message prigin)
+ {
+ MessageType = messageType;
+ Origin = prigin;
+ }
+
+ ///
+ /// constructor
+ ///
+ ///
+ ///
+ ///
+ public AbpCAPExecutionFailedException(MessageType messageType, Message prigin, string message) : base(message)
+ {
+ MessageType = messageType;
+ Origin = prigin;
+ }
+
+ ///
+ /// constructor
+ ///
+ ///
+ ///
+ ///
+ ///
+ public AbpCAPExecutionFailedException(MessageType messageType, Message prigin, string message, Exception innerException) : base(message, innerException)
+ {
+ MessageType = messageType;
+ Origin = prigin;
+ }
+ }
+}
diff --git a/aspnet-core/modules/settings/LINGYUN.Abp.SettingManagement.Application/LINGYUN/Abp/SettingManagement/SettingAppService.cs b/aspnet-core/modules/settings/LINGYUN.Abp.SettingManagement.Application/LINGYUN/Abp/SettingManagement/SettingAppService.cs
index 778e4c245..47f547acb 100644
--- a/aspnet-core/modules/settings/LINGYUN.Abp.SettingManagement.Application/LINGYUN/Abp/SettingManagement/SettingAppService.cs
+++ b/aspnet-core/modules/settings/LINGYUN.Abp.SettingManagement.Application/LINGYUN/Abp/SettingManagement/SettingAppService.cs
@@ -92,10 +92,11 @@ namespace LINGYUN.Abp.SettingManagement
continue;
}
- if (!setting.IsVisibleToClients)
- {
- continue;
- }
+ // 既然是配置服务,那必须能管理所有配置才对
+ //if (!setting.IsVisibleToClients)
+ //{
+ // continue;
+ //}
var settingValue = await SettingManager.GetOrNullAsync(setting.Name, providerName, providerKey);
var settingInfo = new SettingDto
diff --git a/aspnet-core/modules/tenants/LINGYUN.Abp.MultiTenancy.DbFinder/LINGYUN/Abp/MultiTenancy/DbFinder/EventBus/Distributed/TenantCreateEventHandler.cs b/aspnet-core/modules/tenants/LINGYUN.Abp.MultiTenancy.DbFinder/LINGYUN/Abp/MultiTenancy/DbFinder/EventBus/Distributed/TenantCreateEventHandler.cs
index c207ab918..bb832aa11 100644
--- a/aspnet-core/modules/tenants/LINGYUN.Abp.MultiTenancy.DbFinder/LINGYUN/Abp/MultiTenancy/DbFinder/EventBus/Distributed/TenantCreateEventHandler.cs
+++ b/aspnet-core/modules/tenants/LINGYUN.Abp.MultiTenancy.DbFinder/LINGYUN/Abp/MultiTenancy/DbFinder/EventBus/Distributed/TenantCreateEventHandler.cs
@@ -1,4 +1,6 @@
-using System.Threading.Tasks;
+using Microsoft.Extensions.Logging;
+using System;
+using System.Threading.Tasks;
using Volo.Abp.Caching;
using Volo.Abp.Data;
using Volo.Abp.DependencyInjection;
@@ -12,6 +14,7 @@ namespace LINGYUN.Abp.MultiTenancy.DbFinder.EventBus.Distributed
{
public class TenantCreateEventHandler : IDistributedEventHandler>, ITransientDependency
{
+ private readonly ILogger _logger;
private readonly ICurrentTenant _currentTenant;
private readonly ITenantRepository _tenantRepository;
private readonly IDistributedCache _cache;
@@ -19,9 +22,11 @@ namespace LINGYUN.Abp.MultiTenancy.DbFinder.EventBus.Distributed
public TenantCreateEventHandler(
ICurrentTenant currentTenant,
ITenantRepository tenantRepository,
+ ILogger logger,
IDistributedCache cache)
{
_cache = cache;
+ _logger = logger;
_currentTenant = currentTenant;
_tenantRepository = tenantRepository;
}
@@ -29,22 +34,29 @@ namespace LINGYUN.Abp.MultiTenancy.DbFinder.EventBus.Distributed
[UnitOfWork]
public virtual async Task HandleEventAsync(EntityCreatedEto eventData)
{
- using (_currentTenant.Change(null))
+ try
{
- var tenant = await _tenantRepository.FindAsync(eventData.Entity.Id, true);
- if (tenant == null)
+ using (_currentTenant.Change(null))
{
- return;
- }
- var connectionStrings = new ConnectionStrings();
- foreach (var tenantConnectionString in tenant.ConnectionStrings)
- {
- connectionStrings[tenantConnectionString.Name] = tenantConnectionString.Value;
- }
- var cacheItem = new TenantConfigurationCacheItem(tenant.Id, tenant.Name, connectionStrings);
+ var tenant = await _tenantRepository.FindAsync(eventData.Entity.Id, true);
+ if (tenant == null)
+ {
+ return;
+ }
+ var connectionStrings = new ConnectionStrings();
+ foreach (var tenantConnectionString in tenant.ConnectionStrings)
+ {
+ connectionStrings[tenantConnectionString.Name] = tenantConnectionString.Value;
+ }
+ var cacheItem = new TenantConfigurationCacheItem(tenant.Id, tenant.Name, connectionStrings);
- var cacheKey = TenantConfigurationCacheItem.CalculateCacheKey(eventData.Entity.Id.ToString());
- await _cache.SetAsync(cacheKey, cacheItem);
+ var cacheKey = TenantConfigurationCacheItem.CalculateCacheKey(eventData.Entity.Id.ToString());
+ await _cache.SetAsync(cacheKey, cacheItem);
+ }
+ }
+ catch (Exception ex)
+ {
+ _logger.LogException(ex);
}
}
}
diff --git a/aspnet-core/modules/tenants/LINGYUN.Abp.MultiTenancy.DbFinder/LINGYUN/Abp/MultiTenancy/DbFinder/EventBus/Distributed/TenantUpdateEventHandler.cs b/aspnet-core/modules/tenants/LINGYUN.Abp.MultiTenancy.DbFinder/LINGYUN/Abp/MultiTenancy/DbFinder/EventBus/Distributed/TenantUpdateEventHandler.cs
index 4fe9dd599..86f0e7ddc 100644
--- a/aspnet-core/modules/tenants/LINGYUN.Abp.MultiTenancy.DbFinder/LINGYUN/Abp/MultiTenancy/DbFinder/EventBus/Distributed/TenantUpdateEventHandler.cs
+++ b/aspnet-core/modules/tenants/LINGYUN.Abp.MultiTenancy.DbFinder/LINGYUN/Abp/MultiTenancy/DbFinder/EventBus/Distributed/TenantUpdateEventHandler.cs
@@ -1,4 +1,6 @@
-using System.Threading.Tasks;
+using Microsoft.Extensions.Logging;
+using System;
+using System.Threading.Tasks;
using Volo.Abp.Caching;
using Volo.Abp.Data;
using Volo.Abp.DependencyInjection;
@@ -12,6 +14,7 @@ namespace LINGYUN.Abp.MultiTenancy.DbFinder.EventBus.Distributed
{
public class TenantUpdateEventHandler : IDistributedEventHandler>, ITransientDependency
{
+ private readonly ILogger _logger;
private readonly ICurrentTenant _currentTenant;
private readonly ITenantRepository _tenantRepository;
private readonly IDistributedCache _cache;
@@ -19,9 +22,11 @@ namespace LINGYUN.Abp.MultiTenancy.DbFinder.EventBus.Distributed
public TenantUpdateEventHandler(
ICurrentTenant currentTenant,
ITenantRepository tenantRepository,
+ ILogger logger,
IDistributedCache cache)
{
_cache = cache;
+ _logger = logger;
_currentTenant = currentTenant;
_tenantRepository = tenantRepository;
}
@@ -29,22 +34,29 @@ namespace LINGYUN.Abp.MultiTenancy.DbFinder.EventBus.Distributed
[UnitOfWork]
public virtual async Task HandleEventAsync(EntityUpdatedEto eventData)
{
- using (_currentTenant.Change(null))
+ try
{
- var tenant = await _tenantRepository.FindAsync(eventData.Entity.Id, true);
- if (tenant == null)
+ using (_currentTenant.Change(null))
{
- return;
- }
- var connectionStrings = new ConnectionStrings();
- foreach (var tenantConnectionString in tenant.ConnectionStrings)
- {
- connectionStrings[tenantConnectionString.Name] = tenantConnectionString.Value;
- }
- var cacheItem = new TenantConfigurationCacheItem(tenant.Id, tenant.Name, connectionStrings);
+ var tenant = await _tenantRepository.FindAsync(eventData.Entity.Id, true);
+ if (tenant == null)
+ {
+ return;
+ }
+ var connectionStrings = new ConnectionStrings();
+ foreach (var tenantConnectionString in tenant.ConnectionStrings)
+ {
+ connectionStrings[tenantConnectionString.Name] = tenantConnectionString.Value;
+ }
+ var cacheItem = new TenantConfigurationCacheItem(tenant.Id, tenant.Name, connectionStrings);
- var cacheKey = TenantConfigurationCacheItem.CalculateCacheKey(eventData.Entity.Id.ToString());
- await _cache.SetAsync(cacheKey, cacheItem);
+ var cacheKey = TenantConfigurationCacheItem.CalculateCacheKey(eventData.Entity.Id.ToString());
+ await _cache.SetAsync(cacheKey, cacheItem);
+ }
+ }
+ catch(Exception ex)
+ {
+ _logger.LogException(ex);
}
}
}
diff --git a/aspnet-core/services/platform/LINGYUN.Platform.HttpApi.Host/AppPlatformHttpApiHostModule.cs b/aspnet-core/services/platform/LINGYUN.Platform.HttpApi.Host/AppPlatformHttpApiHostModule.cs
index 1a23b6508..259db5ba4 100644
--- a/aspnet-core/services/platform/LINGYUN.Platform.HttpApi.Host/AppPlatformHttpApiHostModule.cs
+++ b/aspnet-core/services/platform/LINGYUN.Platform.HttpApi.Host/AppPlatformHttpApiHostModule.cs
@@ -1,4 +1,5 @@
using DotNetCore.CAP;
+using DotNetCore.CAP.Internal;
using IdentityModel;
using LINGYUN.Abp.Domain.Entities.Events;
using LINGYUN.Abp.EventBus.CAP;
@@ -121,7 +122,7 @@ namespace LINGYUN.Platform
Configure(options =>
{
// 加入需要处理的异常类型
- options.Handlers.Add();
+ options.Handlers.Add();
});
// 自定义需要发送邮件通知的异常类型
Configure(options =>
@@ -131,7 +132,7 @@ namespace LINGYUN.Platform
// 未指定异常接收者的默认接收邮件
options.DefaultReceiveEmail = "colin.in@foxmail.com";
// 指定某种异常发送到哪个邮件
- options.HandReceivedException("colin.in@foxmail.com");
+ options.HandReceivedException("colin.in@foxmail.com");
});
Configure(options =>