Rashmi Prbhath Rashmi Prbhath - 2 months ago 14
Java Question

Delay of Cassandra cluster.close

I am new to Cassandra. I implemented a Java Cassandra Connector in each method a new cluster will be build and end of the method I close it.

but

cluster.close()
method take too much time to finish.

Then I tried
cluster.closeAsync()
but it did not help much. What should I do?

Answer

Usually you open the connection once per application, keep it open, reuse the session object (the connect method returns that object) all over the places in the application, and you apply this criteria until you are done with the cluster. I mean, when your application finishes its work: you close both session and cluster only when your application quits or you need to release resources for a while. That's how the driver is supposed to be used.

Please find more on DataStax site

Comments