Rashmi Prbhath Rashmi Prbhath - 1 month ago 4x
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.


method take too much time to finish.

Then I tried
but it did not help much. What should I do?


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