0

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()); 
                                  } 
                               }); 
                           } 

1 Answers1

3

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

Stefan Podkowinski
  • 5,206
  • 1
  • 20
  • 25