最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

java - Akka entity.discardBytes with Unmarshaller function - Stack Overflow

programmeradmin1浏览0评论

I have this function for POST http calls:

public static String post(ActorSystem system, String uri, String json) throws Exception {
    try {
        HttpRequest post = HttpRequest.POST(uri).withEntity(HttpEntities.create(ContentTypes.APPLICATION_JSON, json));
        return Http.get(system).singleRequest(post).thenCompose(response -> {
            if (response.status().isFailure()) {
                response.discardEntityBytes(system);
                return CompletableFuturepletedFuture(null);
            }
            else{
                return Unmarshaller.entityToString().unmarshal(response.entity(), system);
            }
        }).toCompletableFuture().get();
    } catch (Exception e) {
        throw e;
    }
}

Sometimes receive this error:

java.util.concurrent.TimeoutException: Response entity was not subscribed after 5 seconds. Make sure to read the response entity body or call entity.discardBytes() on it -- in case you deal with HttpResponse, use the shortcut response.discardEntityBytes(). POST /some/path/service Strict(38450 bytes) -> 200 OK Chunked

I have see the warning note in .html

How to I can fix/solve this in "else" case?

Tnx

ps: increment timeout is a weak solution :(

发布评论

评论列表(0)

  1. 暂无评论