-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
70 lines (45 loc) · 1.52 KB
/
Copy pathProgram.cs
File metadata and controls
70 lines (45 loc) · 1.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
using Hangfire;
using Hangfire.PostgreSql;
using HangfireDemo;
using HangfireDemo.GraphQL;
var builder = WebApplication.CreateBuilder(args);
var configuration = builder.Configuration;
builder.Services.AddHangfire((serviceProvider, config) =>
{
config.UsePostgreSqlStorage(c =>
c.UseNpgsqlConnection(configuration.GetConnectionString("HangfireConnection")));
// config.UseActivator(new TestJobActivator(serviceProvider.GetRequiredService<IServiceScopeFactory>()));
//config.UseFilter(new ExampleJobFilter());
});
//Server where you don't set any options will use a "default" queue and use 20 workers.
builder.Services.AddHangfireServer();
builder.Services.AddHangfireServer(options =>
{
options.SchedulePollingInterval = TimeSpan.FromSeconds(2);
options.Queues = [Constants.FastQueue];
});
builder.Services.AddHangfireServer(options =>
{
options.Queues = [Constants.SlowQueue, Constants.QueueNumberTwo];
options.ServerName = "MyLimitedServer";
options.WorkerCount = 5;
});
builder.Services.AddScoped<BackgroundJobService>();
builder.Services.AddScoped<BulkExampleService>();
builder.Services
.AddGraphQLServer()
.AddQueryType<Query>()
.AddMutationType<Mutation>()
.AddSubscriptionType<Subscription>()
.AddInMemorySubscriptions();
var app = builder.Build();
// Configure the HTTP request pipeline.
if (!app.Environment.IsDevelopment())
{
app.UseExceptionHandler("/Error");
}
app.UseRouting();
app.UseHangfireDashboard();
app.UseWebSockets();
app.MapGraphQL();
app.Run();