Reputation: 417
I am using datastax driver to do cassandra writes asynchronously, would like to see if there is a way to retry writes on failure. It does not seem to contain the request in Throwable throwable during failure.
public void onQueryComplete(final ResultSetFuture rsf)
{
Futures.addCallback(rsf, new FutureCallback<ResultSet>()
{
@Override
public void onSuccess(ResultSet resultSet)
{
totalRecordsWritten.incrementAndGet();
jobContext.putLong("MDPREC_WRITE_CNT", totalRecordsWritten.get());
System.out.println("Ingestion succesful " + totalRecordsWritten.get());
Logging.log(Logging.INFO, "CassandraPersistence.java ingest() Ingestion succesful");
}
@Override public void onFailure(Throwable throwable)
{
jobContext.putInt("MDP_WRITE_FAILED", 1);
Logging.log(Logging.INFO,"CassandraPersistence.java ingest() Ingestion failed"); throw
new UnexpectedJobExecutionException("Exception while inserting data Job terminated"+throwable.getMessage());
}
});
}
Upvotes: 0
Views: 621
Reputation: 5249
You can implement your own retry strategy in case you don't want to save each query along with the result handler:
http://christopher-batey.blogspot.de/2013/10/cassandra-datastax-java-driver-retry.html
Upvotes: 3