Browse Source

#3382 Throw exception instead of warning if background job execution was disabled but still trying to execute.

pull/4021/head
Halil İbrahim Kalkan 6 years ago
parent
commit
956d6b68a4
  1. 12
      framework/src/Volo.Abp.BackgroundJobs.HangFire/Volo/Abp/BackgroundJobs/Hangfire/HangfireJobExecutionAdapter.cs

12
framework/src/Volo.Abp.BackgroundJobs.HangFire/Volo/Abp/BackgroundJobs/Hangfire/HangfireJobExecutionAdapter.cs

@ -8,8 +8,6 @@ namespace Volo.Abp.BackgroundJobs.Hangfire
{
public class HangfireJobExecutionAdapter<TArgs>
{
public ILogger<HangfireJobExecutionAdapter<TArgs>> Logger { get; set; }
protected AbpBackgroundJobOptions Options { get; }
protected IServiceScopeFactory ServiceScopeFactory { get; }
protected IBackgroundJobExecuter JobExecuter { get; }
@ -22,15 +20,19 @@ namespace Volo.Abp.BackgroundJobs.Hangfire
JobExecuter = jobExecuter;
ServiceScopeFactory = serviceScopeFactory;
Options = options.Value;
Logger = NullLogger<HangfireJobExecutionAdapter<TArgs>>.Instance;
}
public void Execute(TArgs args)
{
if (!Options.IsJobExecutionEnabled)
{
Logger.LogWarning("Background jobs system is disabled");
return;
throw new AbpException(
"Background job execution is disabled. " +
"This method should not be called! " +
"If you want to enable the background job execution, " +
$"set {nameof(AbpBackgroundJobOptions)}.{nameof(AbpBackgroundJobOptions.IsJobExecutionEnabled)} to true! " +
"If you've intentionally disabled job execution and this seems a bug, please report it."
);
}
using (var scope = ServiceScopeFactory.CreateScope())

Loading…
Cancel
Save