Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/357.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 503错误后的活动重试作业_Java_Activiti - Fatal编程技术网

Java 503错误后的活动重试作业

Java 503错误后的活动重试作业,java,activiti,Java,Activiti,我有许多服务任务称为rest服务,有时服务不可用。我希望在JavaDelegate中能够无限次重试作业: @Override public void execute(DelegateExecution execution) { try { //call_rest_service } catch (Exception503 error) { CommandContext commandContext = Context.get

我有许多服务任务称为rest服务,有时服务不可用。我希望在JavaDelegate中能够无限次重试作业:

@Override
public void execute(DelegateExecution execution)
{
    try
    {
        //call_rest_service
    }
    catch (Exception503 error)
    {
        CommandContext commandContext = Context.getCommandContext();
        JobEntity jobEntity = commandContext.getJobEntityManager().findById(job.getId());
        jobEntity.setRetries(10);
        //then throw original error
    }
}

但这似乎不起作用

我认为这是一种草率的做事方式,但如果你确定这就是你想要做的,我建议你做如下事情:

@Override
public void execute(DelegateExecution execution)
{
    int retryMax = 10, retryCount =0;
    while (retryCount++ < retryMax){
      try
      {
        //call_rest_service
      }
      catch (Exception503 error)
      {
        // sleep to not DDoS the server
        Thread.sleep(500);
      }
    }
}
@覆盖
公共作废执行(委托执行)
{
int retryMax=10,retryCount=0;
while(retryCount++