admin管理员组文章数量:1317898
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 :(
本文标签: javaAkka entitydiscardBytes with Unmarshaller functionStack Overflow
版权声明:本文标题:java - Akka entity.discardBytes with Unmarshaller function - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742033043a2416805.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论