Will Quartz.net 作业将在下一次迭代中 运行 即使有任何异常
Will Quartz.net job will run on the next iteration even if there is any exception
可能是个愚蠢的问题...但无论如何...
我想知道 quartz.net 作业是否会在下一次迭代中激活到 运行,尽管当前迭代中存在异常(已处理)。如果我的理解正确,谁能解释一下?
public void Execute(IJobExecutionContext context)
{
_logProvider.Info("Started..");
try
{
_service.Calculate();
}
catch (Exception ex)
{
_logProvider.Error("Error " + ex);
}
}
谢谢
简单的回答是:是的,它将在下一次迭代时执行。
实际上这与一般的 .NET 异常处理有关,而不是 quartz.net 行为:
如果你有捕获任何异常的函数——异常在该函数之外是不可见的。换句话说,代码像
public void SomeMethod()
{
try
{
//some logic that can generate exception
}
catch (Exception ex)
{
}
}
与
相同
public void SomeMethod()
{
//some logic that NEVER generates the exception
}
在quartz.net范围内:
The only type of exception that you are allowed to throw from the execute method is JobExecutionException.
否则您将在 AppDomain 中遇到未处理的异常。您可以在 Quartz.net Job unhandled exception behaviour SO 问题
中找到更多信息
可能是个愚蠢的问题...但无论如何...
我想知道 quartz.net 作业是否会在下一次迭代中激活到 运行,尽管当前迭代中存在异常(已处理)。如果我的理解正确,谁能解释一下?
public void Execute(IJobExecutionContext context)
{
_logProvider.Info("Started..");
try
{
_service.Calculate();
}
catch (Exception ex)
{
_logProvider.Error("Error " + ex);
}
}
谢谢
简单的回答是:是的,它将在下一次迭代时执行。
实际上这与一般的 .NET 异常处理有关,而不是 quartz.net 行为: 如果你有捕获任何异常的函数——异常在该函数之外是不可见的。换句话说,代码像
public void SomeMethod()
{
try
{
//some logic that can generate exception
}
catch (Exception ex)
{
}
}
与
相同public void SomeMethod()
{
//some logic that NEVER generates the exception
}
在quartz.net范围内:
The only type of exception that you are allowed to throw from the execute method is JobExecutionException.
否则您将在 AppDomain 中遇到未处理的异常。您可以在 Quartz.net Job unhandled exception behaviour SO 问题
中找到更多信息