Retry Policy

Often, queries might fail due to temporary network outages or increased load on a node. It doesn't make sense to fail such queries immediately. Java driver provides a set of policies to ensure queries are retried a certain number of times before throwing exceptions. This accounts for temporary failures. You can create your own retry policy as well.

To set retrypolicy, you will have to use the withRetryPolicy() method of the Cluster.Builder object:

Cluster cluster = Cluster.builder().addContactPoints("127.0.0.1").withRetryPolicy(RetryPolicy policy).build();

Here are some of the retry policies available in Java driver:

  • DefaultRetryPolicy: This policy retries a failed query a certain number of times. It retries queries on a read ...

Get Learning Apache Cassandra - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.