小编Bas*_*hdy的帖子

REST RQL Java实现

有没有"RQL"(资源查询语言)的java实现,这里有一个"FIQL"(Feed Item Query Language)的实现,但它是CXF的一部分,所以我的问题是:

  1. 如果我使用的是Spring MVC,我可以使用CXF实现的FIQL引擎与使用CXF分开吗?
  2. 是否有RQL的实现
  3. RQL与FIQL

java rest search-engine

8
推荐指数
1
解决办法
4451
查看次数

CompletableFuture 递归确保可靠性

这是非常基本的递归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)

java recursion functional-programming future java-8

5
推荐指数
1
解决办法
4377
查看次数