if( results == null )
throw new ApplicationException("返回结果为空!");
//Map<String,JobQueue> map = new HashMap<String,JobQueue>();
for(Result result:results ){
JobQueue item = (JobQueue)result.getObject();
if( item == null ){//TODO
throw new ApplicationException("返回结果Result[key="
+result.getKey()+"]关联Object为空!");
}
if( !result.isSuccess() && item != null ){
item.incFailureCount();
item.setStatus(JobQueue.Status.FAILURE );
item.setErrMsg(result.getMessage());
}
}
}catch( Exception e ){
results = new ArrayList<Result>();
for(JobQueue item:items){
results.add(new Result(false,item.getRefId(),item,e.getMessage()));
item.incFailureCount();
item.setStatus( JobQueue.Status.FAILURE );
String errMsg = e.getMessage()+(e.getCause()==null?"":e.getCause().getMessage());
item.setErrMsg( errMsg.length()>199?errMsg.substring(0,199):errMsg );
log.error("任务队列[id="+item.getIdentity()+",type="
+item.getType().getName()+",ref_id="
+item.getRefId()+"]执行异常:",e);
}
}
List<JobQueue> outQueues = new ArrayList<JobQueue>();//成功队列
List<JobQueue> updateQueues = new ArrayList<JobQueue>();//更新队列
for(Result item:results ){
JobQueue jobQueue = (JobQueue)item.getObject();
if( item.isSuccess() || jobQueue.isDeletable() )
outQueues.add(jobQueue);
else
updateQueues.add(jobQueue);
}