简体   繁体   中英

Apache Jena - Internal Ping Timeout does not work

Many public SPARQL Endpoint Services owe a Ping Timeout of 30 seconds. This is way too long for my program as I want to have it around 10 seconds.

There is a function in Apache Jena for an internal Ping Timeout, but apparently it doesn't work as I tested with some queries which take way longer than 10 seconds. I tried many variations with my code below. If someone posts similar lines of code, please test if it really works . I appreciate any help.

Also another question: Would the internal Ping Timeout from Apache Jena also work if the SPARQL Endpoint Service is down? It would be really helpful to throw an Exception as the user in my program won't have to desperately wait for an answer.

Java Code snip:

import java.util.concurrent.TimeUnit;

public static ResultSet executeQuery(String queryString, String service) {
    Query query = QueryFactory.create(queryString);
    QueryEngineHTTP queryEngine = QueryExecutionFactory.createServiceRequest(service, query);
    queryEngine.setTimeout(15, TimeUnit.SECONDS);
    ResultSet resultSet = queryEngine.execSelect();
    return resultSet;
}

The timeout from the remote service is under the control of the remote service. They may provide endpoint-specific ways to set the timeout (see their documentation). Jena has no other control of the remote execution for a query timeout on the server.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM