有没有"RQL"(资源查询语言)的java实现,这里有一个"FIQL"(Feed Item Query Language)的实现,但它是CXF的一部分,所以我的问题是:
这是非常基本的递归CompletableFuture
,我想建立可靠的系统,所以每次遇到异常都要重新启动进程,我相信它有太多问题,并且希望得到您的反馈
private CompletableFuture<?> recursion() {
return CompletableFuture.runAsync(() -> {
//code here
}).handleAsync((v, th) -> {
if (th != null)
return this.recursion();
else
return v;
});
}
Run Code Online (Sandbox Code Playgroud)
编辑1:
int tries =5;
private CompletableFuture<?> recursion() {
return CompletableFuture.runAsync(() -> {
//code here
}).handleAsync((v, th) -> {
if (th != null && tries-- > 0){
Thread.sleep(1000);
return this.recursion();
}else
return v;
});
}
Run Code Online (Sandbox Code Playgroud)
Edit2:清理代码,因为返回 CompletableFuture<?>
不需要,所以void
考虑到 @Holger 注释并使用 AtomicInteger 进行尝试,将其挂起以返回
AtomicInteger tries =5;
private void recursion() {
CompletableFuture.runAsync(() -> …
Run Code Online (Sandbox Code Playgroud)