yuzd / Hangfire.HttpJob

httpjob for Hangfire,restful api for Hangfire,job调度与业务分离
https://github.com/yuzd/Hangfire.HttpJob/wiki
MIT License
626 stars 185 forks source link

任务执行成功后一直处于执行中状态 #93

Closed zxyao145 closed 3 years ago

zxyao145 commented 3 years ago

问题描述: 任务在执行成功后一直处于执行中状态,debug时可以看到确实执行完毕,且未抛出异常。

代码结构:

[TransientJob]
public class AlertJob:JobAgent
{
    private readonly ILogger<AlertJob> _logger;
    private readonly IAlertCalcService _alertCalcService;

    public AlertJob(
        ILogger<AlertJob> logger,
        IAlertCalcService alertCalcService
    )
    {
        _logger = logger;
        _alertCalcService = alertCalcService;

    }

    public override async Task OnStart(JobContext jobContext)
    {
        await AlertCalcJob();
    }

    public async Task AlertCalcJob()
    {
        _logger.LogInformation("AlertCalcJob");
        await _alertCalcService.RunAsync();
    }
}

相关环境: -- NET 5.0

-- 调度端依赖 <PackageReference Include="Hangfire.AspNetCore" Version="1.7.18" /> <PackageReference Include="Hangfire.HttpJob" Version="3.4.9" /> <PackageReference Include="Hangfire.HttpJob.Client" Version="1.2.1" /> <PackageReference Include="Hangfire.PostgreSql" Version="1.8.0" /> <PackageReference Include="Hangfire.RecurringJobAdmin" Version="1.0.5" /> <PackageReference Include="Hangfire.RecurringJobExtensions" Version="1.1.6" /> <PackageReference Include="HangFire.Redis.StackExchange" Version="1.8.4" />

-- Agent端依赖 <PackageReference Include="Hangfire.HttpJob.Agent" Version="1.3.3" />

yuzd commented 3 years ago

请查看一下agent端是否可以连接到hangfire的storage

yuzd commented 3 years ago

看你的引用只有agent并没有按照wiki来,wiki说明了要么你用mysql 或者 sqlserver或者redis的agent nuget包,你再看看wiki

yuzd commented 3 years ago

625AA09C-1F73-442E-8F2A-3963FDB7C23B

zxyao145 commented 3 years ago

这个是新增的吗?以前使用NET Core 3的时候没问题,最近升级了发现无法使用了

yuzd commented 3 years ago

我的demo你看下

yuzd commented 3 years ago

新版有点变化了,变得更好了。你可以看看wiki