这是我的行动,
当错误时,我希望retryWhen
会重复当前项目,但它会从头开始重复整个过程,我尝试修改它但不会重复并抛出异常。
return Observable.fromArray(getTodayShareHolding(dd,MM,yyyy,tmpTicker, item.getId())).retryWhen(errors -> errors.flatMap(error -> Observable.timer(5, TimeUnit.SECONDS) ) );
然后我尝试修改这样的代码
@GetMapping(path = "operaion")
public @ResponseBody void operation(@RequestParam(value = "startDate", required = true) String startDate, @RequestParam(value = "endDate", required = true) String endDate ) throws IOException, ParseException {
List <EntityList> plist = EntityListListRepository.findByPendingDayBetweenAndIsProcessedFalseAndIsUpdatedFalse(formatDate(startDate), formatDate(endDate) );
long startTime = System.currentTimeMillis();
Observable.fromIterable(plist).concatMap( item -> {
Calendar cal = Calendar.getInstance();
cal.setTime(item.getPendingDay());
Integer yyyy = cal.get(Calendar.YEAR);
Integer MM = cal.get(Calendar.MONTH)+1;
Integer dd = cal.get(Calendar.DAY_OF_MONTH);
String tmpId = item.getTmpId().toString();
Integer delayCheck = item.getTmpId();
Integer delayMiniSec = 0;
if(delayCheck >= 70000) {
delayMiniSec = 0;
}
Date currentTime = new Date();
System.out.println("Step1 ::{ : "+dd+"/"+MM+"/"+yyyy+"@"+tmpId+" id = ["+item.getId()+"] } startInsert time = "+currentTime);
return Observable.fromArray(fetchList(dd,MM,yyyy,tmpId, item.getId()))
}).retryWhen(errors -> errors.flatMap(error -> Observable.timer(5, TimeUnit.SECONDS) ) );
.subscribe(System.out::println);
它会在开始发生时重复整个过程, 有人给我一些建议吗?
更新: 或者我尝试下面这样的事情? http://aspects.jcabi.com/annotation-retryonfailure.html