Reputation: 1618
Following code where I'm trying to run cross partition query is getting stuck on it.hasNext() line. Not able to debug further here :
public List<MyDataObject> getList() {
List<Document> documentList =null;
List<MyDataObject> returnList = new ArrayList<>();
try {
FeedOptions feedOptions = new FeedOptions();
feedOptions.setEnableCrossPartitionQuery(true);
SqlQuerySpec querySpec = null;
querySpec = new SqlQuerySpec("SELECT * FROM MyDataObjectColl");
Iterator<FeedResponse<Document>> getDataFromCosmos = myDocumentClient.queryDocuments(collectionLink, querySpec, feedOptions).toBlocking().getIterator();
while (getDataFromCosmos.hasNext()) { //GETTING STUCK ON THIS LINE FOR SOME REASON
FeedResponse<Document> page = getDataFromCosmos.next();
System.out.println("Request Unit Cost for getList " + page.getRequestCharge());
documentList = page.getResults();
for (Document doc : documentList) {
if (doc != null) {
returnList.add(gson.fromJson(doc.toJson(), MyDataObject.class));
}
}
}
} catch (Exception e) {
throw new RuntimeException(e);
}
return returnList;
}
SDK version :
<dependency>
<groupId>com.microsoft.azure</groupId>
<artifactId>azure-cosmosdb</artifactId>
<version>2.4.4</version>
</dependency>
Hey, CosmosDB internal expert please point out what could have caused this behavior I'm suspecting some library is missing which is getting blocking, please help.
Upvotes: 0
Views: 290
Reputation: 1618
As suspected there was version issue which was causing this, basically my application internal library was using following version of commons-lang3 :
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.3.1</version>
</dependency>
But azure-cosmosdb 2.4.4 requires different :
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.8.1</version>
</dependency>
Detail explanation:
Basically cosmosdb internally in class FetchExecutionRangeAccumulator uses a line this.stopwatch.getTime(TimeUnit.MILLISECONDS)
but long getTime(final TimeUnit timeUnit)
is present in 3.8.1 version of commons-lang3 not in 3.3.1 due to which it was internally getting stuck at polling code and was intermittently throwing exception (method not found in commons-lang3) if retry same code flow.
Upvotes: 1