committed by
GitHub
16 changed files with 175 additions and 15 deletions
@ -0,0 +1,21 @@ |
|||
namespace LINGYUN.Abp.Notifications |
|||
{ |
|||
public class AbpNotificationCleanupOptions |
|||
{ |
|||
/// <summary>
|
|||
/// 是否启用清理任务
|
|||
/// 默认:启用
|
|||
/// </summary>
|
|||
public bool IsEnabled { get; set; } = true; |
|||
/// <summary>
|
|||
/// 清理时间间隔
|
|||
/// 默认:300000ms
|
|||
/// </summary>
|
|||
public int CleanupPeriod { get; set; } = 300000; |
|||
/// <summary>
|
|||
/// 清理批次
|
|||
/// 默认: 200
|
|||
/// </summary>
|
|||
public int CleanupBatchSize { get; set; } = 200; |
|||
} |
|||
} |
|||
@ -0,0 +1,41 @@ |
|||
using Microsoft.Extensions.DependencyInjection; |
|||
using Microsoft.Extensions.Logging; |
|||
using Microsoft.Extensions.Options; |
|||
using System; |
|||
using System.Threading.Tasks; |
|||
using Volo.Abp.BackgroundWorkers; |
|||
using Volo.Abp.Threading; |
|||
|
|||
namespace LINGYUN.Abp.Notifications.Internal |
|||
{ |
|||
internal class NotificationCleanupBackgroundWorker : AsyncPeriodicBackgroundWorkerBase |
|||
{ |
|||
protected AbpNotificationCleanupOptions Options { get; } |
|||
|
|||
public NotificationCleanupBackgroundWorker( |
|||
AbpTimer timer, |
|||
IServiceScopeFactory serviceScopeFactory, |
|||
IOptions<AbpNotificationCleanupOptions> options) |
|||
: base(timer, serviceScopeFactory) |
|||
{ |
|||
Options = options.Value; |
|||
timer.Period = Options.CleanupPeriod; |
|||
} |
|||
|
|||
protected override async Task DoWorkAsync(PeriodicBackgroundWorkerContext workerContext) |
|||
{ |
|||
try |
|||
{ |
|||
var store = workerContext.ServiceProvider.GetRequiredService<INotificationStore>(); |
|||
Logger.LogDebug("Before cleanup exprition jobs..."); |
|||
await store.DeleteNotificationAsync(Options.CleanupBatchSize); |
|||
Logger.LogDebug("Exprition jobs cleanup job was successful..."); |
|||
} |
|||
catch (Exception ex) |
|||
{ |
|||
Logger.LogWarning("Exprition jobs cleanup job was failed..."); |
|||
Logger.LogWarning("Error:{0}", ex.Message); |
|||
} |
|||
} |
|||
} |
|||
} |
|||
4
aspnet-core/modules/message/LINGYUN.Abp.MessageService.Application.Contracts/LINGYUN/Abp/MessageService/AbpMessageServiceApplicationContrantsModule.cs → aspnet-core/modules/message/LINGYUN.Abp.MessageService.Application.Contracts/LINGYUN/Abp/MessageService/AbpMessageServiceApplicationContractsModule.cs
4
aspnet-core/modules/message/LINGYUN.Abp.MessageService.Application.Contracts/LINGYUN/Abp/MessageService/AbpMessageServiceApplicationContrantsModule.cs → aspnet-core/modules/message/LINGYUN.Abp.MessageService.Application.Contracts/LINGYUN/Abp/MessageService/AbpMessageServiceApplicationContractsModule.cs
@ -0,0 +1,23 @@ |
|||
<Project Sdk="Microsoft.NET.Sdk"> |
|||
|
|||
<PropertyGroup> |
|||
<TargetFramework>netcoreapp3.1</TargetFramework> |
|||
<RootNamespace /> |
|||
<GeneratePackageOnBuild>true</GeneratePackageOnBuild> |
|||
<Version>2.9.0</Version> |
|||
<Authors>LINGYUN</Authors> |
|||
</PropertyGroup> |
|||
|
|||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'"> |
|||
<OutputPath>D:\LocalNuget</OutputPath> |
|||
</PropertyGroup> |
|||
|
|||
<ItemGroup> |
|||
<PackageReference Include="Volo.Abp.Http.Client" Version="2.9.0" /> |
|||
</ItemGroup> |
|||
|
|||
<ItemGroup> |
|||
<ProjectReference Include="..\LINGYUN.Abp.MessageService.Application.Contracts\LINGYUN.Abp.MessageService.Application.Contracts.csproj" /> |
|||
</ItemGroup> |
|||
|
|||
</Project> |
|||
@ -0,0 +1,20 @@ |
|||
using Microsoft.Extensions.DependencyInjection; |
|||
using Volo.Abp.Http.Client; |
|||
using Volo.Abp.Modularity; |
|||
|
|||
namespace LINGYUN.Abp.MessageService |
|||
{ |
|||
[DependsOn( |
|||
typeof(AbpMessageServiceApplicationContractsModule), |
|||
typeof(AbpHttpClientModule))] |
|||
public class AbpMessageServiceHttpApiClientModule : AbpModule |
|||
{ |
|||
public override void ConfigureServices(ServiceConfigurationContext context) |
|||
{ |
|||
context.Services.AddHttpClientProxies( |
|||
typeof(AbpMessageServiceApplicationContractsModule).Assembly, |
|||
AbpMessageServiceConsts.RemoteServiceName |
|||
); |
|||
} |
|||
} |
|||
} |
|||
Loading…
Reference in new issue