I have a use case in which I want updated data from the Couchbase so when I query couchbase for the data simply like:
bucket.get.query(Query.simple(query))
It gives me updated data, upto some time , but as the size of the data base increases it does not provide me updated and consistent data. Here the query is scanning an index and providing the required data accordingly. So for getting the consistent data I used the ScanConsistency.REQUESTPLUS as suggested by couchbase documentation. But as soon as I change the code and do something like this:
bucket.get.query(Query.simple(query, QueryParams.build().consistency(ScanConsistency.REQUEST_PLUS)
.serverSideTimeout(10000, TimeUnit.SECONDS)))
It gives me a timeout Exception each and everytime and never returns me the result. Can you please explain how can I achieve the consistency of the data here and why it is always giving me timeout exception.
StackTrace:
java.lang.RuntimeException: java.util.concurrent.TimeoutException
[error] at com.couchbase.client.java.util.Blocking.blockForSingle(Blocking.java:93)
[error] at com.couchbase.client.java.CouchbaseBucket.query(CouchbaseBucket.java:548)
[error] at com.couchbase.client.java.CouchbaseBucket.query(CouchbaseBucket.java:491)
Any help is appreciated.!
Some versions of the SDK introduced Experimental support for N1QL before version 2.2.0
, which was the 1st version to officially support N1QL in a non-beta state (that is to say, in pair with Couchbase Server 4.0).
I notice that you don't use such a version, because QueryParams
was renamed to N1qlParams
in 2.2.0. So you need to upgrade to the latest SDK 2.2.x (2.2.5 should be out in a few days).
Also you can set a server side timeout (and you did in your example) but there is always a client side timeout (at least when you use the Bucket
api). If you don't increase it in accordance to the server side timeout you set, you'll receive a RuntimeException
wrapping a TimeoutException
(the client side timeout will trigger).