You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@jena.apache.org by Dalkandura Arachchige Gunaratna <gu...@wright.edu> on 2011/06/20 18:32:48 UTC
Jena ARQ API - how to set timeout in Java
Hi,
I am using Jena ARQ API to query DBpedia dataset using a sparql endpoint. I want to set the timeout limit for querying using a java program so that the program will not crash if sufficient timeout is set. My intention is to have a simple loop to handle so that if an exception happens, the query will be re-done.
I have come across a code sample to set timeout in the internet and I am not sure whether this works correctly. Is this correct or there is any other way of doing this?
QueryEngineHTTP qexec = (QueryEngineHTTP) QueryExecutionFactory.sparqlService(
strSparqlEndpoint, qExecuteQuery);
qexec.addParam("timeout","10000");
Kalpa Gunaratna
Re: Jena ARQ API - how to set timeout in Java
Posted by Andy Seaborne <an...@epimorphics.com>.
On 21/06/11 16:21, Dalkandura Arachchige Gunaratna wrote:
> Thnx Andy. I have observed that sometimes when I try for several times with the same timeout manually using the DBpedia sparql endpoint, it works. A better strategy would be to increase the timeout from the client side for some iterations before stop querying. But if there is not way to set the timeout for the client side then anyways this would not work.
The people running dbpedia may disagree with you!
> I think I can't set server timeout (DBpedia sparql endpoint) when I am using a java program to query the endpoint. Is there a way that I can set the DBpedia sparql endpoint timeout using a program? Thank you.
>
> Kalpa Gunaratna
There's some kind of protocol request parameter (non-standard) to set
the timeout of the request.
You can set it with QueryEngineHTTP.addParam.
Andy
>
>
>
> ----- Original Message -----
> From: Andy Seaborne<an...@epimorphics.com>
> Date: Tuesday, June 21, 2011 3:38 am
> Subject: Re: Jena ARQ API - how to set timeout in Java
> To: jena-users@incubator.apache.org
>
>>
>>
>> On 20/06/11 17:32, Dalkandura Arachchige Gunaratna wrote:
>>> Hi, I am using Jena ARQ API to query DBpedia dataset using a sparql
>> endpoint. I want to set the timeout limit for querying using a java
>> program so that the program will not crash if sufficient timeout
>> is set.
>> My intention is to have a simple loop to handle so that if an
>> exceptionhappens, the query will be re-done.
>>>
>>> I have come across a code sample to set timeout in the
>> internet and
>>> I
>> am not sure whether this works correctly. Is this correct or
>> there is
>> any other way of doing this?
>>
>>>
>> QueryEngineHTTP qexec = (QueryEngineHTTP)
>> QueryExecutionFactory.sparqlService(> strSparqlEndpoint, qExecuteQuery);
>>>
>> qexec.addParam("timeout","10000");>
>>> Kalpa Gunaratna
>>>
>>>
>>>
>>
>> QueryEngineHTTP itself does not support timeouts:
>>
>> https://issues.apache.org/jira/browse/JENA-56
>>
>> This would be timeout at the local end anyway - in the
>> dbpedia.org (if
>> that is what you are querying) then the timeout can be set so
>> the server
>> times the query out. See the documentation for dbpedia and
>> Virtuoso.
>> In either case, retrying a query is unlikely to be a good
>> strategy - if
>> the query timeouted once, why won't it timeout the next time as well?
>>
>> Andy
>
Re: Jena ARQ API - how to set timeout in Java
Posted by Dalkandura Arachchige Gunaratna <gu...@wright.edu>.
Thnx Andy. I have observed that sometimes when I try for several times with the same timeout manually using the DBpedia sparql endpoint, it works. A better strategy would be to increase the timeout from the client side for some iterations before stop querying. But if there is not way to set the timeout for the client side then anyways this would not work.
I think I can't set server timeout (DBpedia sparql endpoint) when I am using a java program to query the endpoint. Is there a way that I can set the DBpedia sparql endpoint timeout using a program? Thank you.
Kalpa Gunaratna
----- Original Message -----
From: Andy Seaborne <an...@epimorphics.com>
Date: Tuesday, June 21, 2011 3:38 am
Subject: Re: Jena ARQ API - how to set timeout in Java
To: jena-users@incubator.apache.org
>
>
> On 20/06/11 17:32, Dalkandura Arachchige Gunaratna wrote:
> > Hi, I am using Jena ARQ API to query DBpedia dataset using a sparql
> endpoint. I want to set the timeout limit for querying using a java
> program so that the program will not crash if sufficient timeout
> is set.
> My intention is to have a simple loop to handle so that if an
> exceptionhappens, the query will be re-done.
> >
> > I have come across a code sample to set timeout in the
> internet and
> > I
> am not sure whether this works correctly. Is this correct or
> there is
> any other way of doing this?
>
> >
> QueryEngineHTTP qexec = (QueryEngineHTTP)
> QueryExecutionFactory.sparqlService(> strSparqlEndpoint, qExecuteQuery);
> >
> qexec.addParam("timeout","10000");>
> > Kalpa Gunaratna
> >
> >
> >
>
> QueryEngineHTTP itself does not support timeouts:
>
> https://issues.apache.org/jira/browse/JENA-56
>
> This would be timeout at the local end anyway - in the
> dbpedia.org (if
> that is what you are querying) then the timeout can be set so
> the server
> times the query out. See the documentation for dbpedia and
> Virtuoso.
> In either case, retrying a query is unlikely to be a good
> strategy - if
> the query timeouted once, why won't it timeout the next time as well?
>
> Andy
Re: Jena ARQ API - how to set timeout in Java
Posted by Andy Seaborne <an...@epimorphics.com>.
On 20/06/11 17:32, Dalkandura Arachchige Gunaratna wrote:
> Hi, I am using Jena ARQ API to query DBpedia dataset using a sparql
endpoint. I want to set the timeout limit for querying using a java
program so that the program will not crash if sufficient timeout is set.
My intention is to have a simple loop to handle so that if an exception
happens, the query will be re-done.
>
> I have come across a code sample to set timeout in the internet and
> I
am not sure whether this works correctly. Is this correct or there is
any other way of doing this?
> QueryEngineHTTP qexec = (QueryEngineHTTP) QueryExecutionFactory.sparqlService(
> strSparqlEndpoint, qExecuteQuery);
> qexec.addParam("timeout","10000");
>
> Kalpa Gunaratna
>
>
>
QueryEngineHTTP itself does not support timeouts:
https://issues.apache.org/jira/browse/JENA-56
This would be timeout at the local end anyway - in the dbpedia.org (if
that is what you are querying) then the timeout can be set so the server
times the query out. See the documentation for dbpedia and Virtuoso.
In either case, retrying a query is unlikely to be a good strategy - if
the query timeouted once, why won't it timeout the next time as well?
Andy