mirror of https://github.com/abpframework/abp.git
12 changed files with 141 additions and 44 deletions
@ -0,0 +1,20 @@ |
|||
using Microsoft.Extensions.DependencyInjection; |
|||
using TickerQ.DependencyInjection; |
|||
using TickerQ.Utilities; |
|||
using TickerQ.Utilities.Enums; |
|||
using Volo.Abp.TickerQ; |
|||
|
|||
namespace Microsoft.AspNetCore.Builder; |
|||
|
|||
public static class AbpTickerQApplicationBuilderExtensions |
|||
{ |
|||
public static IApplicationBuilder UseAbpTickerQ(this IApplicationBuilder app, TickerQStartMode qStartMode = TickerQStartMode.Immediate) |
|||
{ |
|||
var abpTickerQFunctionProvider = app.ApplicationServices.GetRequiredService<AbpTickerQFunctionProvider>(); |
|||
TickerFunctionProvider.RegisterFunctions(abpTickerQFunctionProvider.Functions); |
|||
TickerFunctionProvider.RegisterRequestType(abpTickerQFunctionProvider.RequestTypes); |
|||
|
|||
app.UseTickerQ(qStartMode); |
|||
return app; |
|||
} |
|||
} |
|||
@ -0,0 +1,53 @@ |
|||
using System; |
|||
using System.Threading; |
|||
using System.Threading.Tasks; |
|||
using Microsoft.AspNetCore.Builder; |
|||
using Microsoft.AspNetCore.Http; |
|||
using Microsoft.Extensions.DependencyInjection; |
|||
using TickerQ.Utilities.Interfaces.Managers; |
|||
using TickerQ.Utilities.Models.Ticker; |
|||
using Volo.Abp.AspNetCore; |
|||
using Volo.Abp.Autofac; |
|||
using Volo.Abp.BackgroundJobs.DemoApp.Shared; |
|||
using Volo.Abp.BackgroundJobs.DemoApp.Shared.Jobs; |
|||
using Volo.Abp.BackgroundJobs.TickerQ; |
|||
using Volo.Abp.Modularity; |
|||
|
|||
namespace Volo.Abp.BackgroundJobs.DemoApp.TickerQ; |
|||
|
|||
[DependsOn( |
|||
typeof(AbpBackgroundJobsTickerQModule), |
|||
typeof(DemoAppSharedModule), |
|||
typeof(AbpAutofacModule), |
|||
typeof(AbpAspNetCoreModule) |
|||
)] |
|||
public class DemoAppTickerQModule : AbpModule |
|||
{ |
|||
public override async Task OnApplicationInitializationAsync(ApplicationInitializationContext context) |
|||
{ |
|||
var app = context.GetApplicationBuilder(); |
|||
app.UseAbpTickerQ(); |
|||
|
|||
app.UseRouting(); |
|||
app.UseEndpoints(endpoints => |
|||
{ |
|||
endpoints.MapGet("/", async httpContext => |
|||
{ |
|||
await httpContext.Response.WriteAsync("Hello TickerQ!"); |
|||
}); |
|||
}); |
|||
|
|||
await CancelableBackgroundJobAsync(context.ServiceProvider); |
|||
} |
|||
|
|||
private async Task CancelableBackgroundJobAsync(IServiceProvider serviceProvider) |
|||
{ |
|||
var backgroundJobManager = serviceProvider.GetRequiredService<IBackgroundJobManager>(); |
|||
var jobId = await backgroundJobManager.EnqueueAsync(new LongRunningJobArgs { Value = "test-1" }); |
|||
await backgroundJobManager.EnqueueAsync(new LongRunningJobArgs { Value = "test-2" }); |
|||
Thread.Sleep(1000); |
|||
|
|||
var timeTickerManager = serviceProvider.GetRequiredService<ITimeTickerManager<TimeTicker>>(); |
|||
var result = await timeTickerManager.DeleteAsync(Guid.Parse(jobId)); |
|||
} |
|||
} |
|||
@ -0,0 +1,19 @@ |
|||
using System.Threading.Tasks; |
|||
using Microsoft.AspNetCore.Builder; |
|||
using Microsoft.Extensions.DependencyInjection; |
|||
using Microsoft.Extensions.Hosting; |
|||
|
|||
namespace Volo.Abp.BackgroundJobs.DemoApp.TickerQ; |
|||
|
|||
public class Program |
|||
{ |
|||
public static async Task Main(string[] args) |
|||
{ |
|||
var builder = WebApplication.CreateBuilder(args); |
|||
builder.Host.AddAppSettingsSecretsJson().UseAutofac(); |
|||
await builder.AddApplicationAsync<DemoAppTickerQModule>(); |
|||
var app = builder.Build(); |
|||
await app.InitializeApplicationAsync(); |
|||
await app.RunAsync(); |
|||
} |
|||
} |
|||
@ -0,0 +1,24 @@ |
|||
<Project Sdk="Microsoft.NET.Sdk"> |
|||
|
|||
<PropertyGroup> |
|||
<OutputType>Exe</OutputType> |
|||
<TargetFramework>net10.0</TargetFramework> |
|||
</PropertyGroup> |
|||
|
|||
<ItemGroup> |
|||
<ProjectReference Include="..\..\..\..\framework\src\Volo.Abp.Autofac\Volo.Abp.Autofac.csproj" /> |
|||
<ProjectReference Include="..\..\..\..\framework\src\Volo.Abp.BackgroundJobs.TickerQ\Volo.Abp.BackgroundJobs.TickerQ.csproj" /> |
|||
<ProjectReference Include="..\Volo.Abp.BackgroundJobs.DemoApp.Shared\Volo.Abp.BackgroundJobs.DemoApp.Shared.csproj" /> |
|||
<ProjectReference Include="..\..\..\..\framework\src\Volo.Abp.AspNetCore\Volo.Abp.AspNetCore.csproj" /> |
|||
</ItemGroup> |
|||
|
|||
<ItemGroup> |
|||
<None Update="appsettings.json"> |
|||
<CopyToOutputDirectory>Always</CopyToOutputDirectory> |
|||
</None> |
|||
<None Update="appsettings.json"> |
|||
<CopyToOutputDirectory>Always</CopyToOutputDirectory> |
|||
</None> |
|||
</ItemGroup> |
|||
|
|||
</Project> |
|||
@ -0,0 +1,3 @@ |
|||
{ |
|||
|
|||
} |
|||
Loading…
Reference in new issue