I need to use asynchronous queries using Spring framework. I use Cassandra and Java driver from Datastax. How can call the executeAsync method and get the results.
Asked
Active
Viewed 1,454 times
1 Answers
2
I have in mind 3 possible solutions:
executeAsync
returnsResultSetFuture
which hasisDone
method, you can havewhile loop with
!isDoneand jump to some block when it returns
truein
isDone`- There is
addListener
inResultSetFuture
so you can register listener to be fired afterFuture
computation is done
Registers a listener to be run on the given executor. The listener will run when the Future's computation is complete or, if the computation is already complete, immediately.
- You can try similar approach but using
ListenableFuture
from the Guava library since whichResultSetFuture
extends like explained in this stackoverflow question
I think 3rd option is way to go and cleanest.

Community
- 1
- 1

Nenad Bozic
- 3,724
- 19
- 45