I have scenario need to insert list of domain classes using GemfireRepository
but it’s not available, where as, it is available in Cassandra using...
@Autowired
private CassandraOperations cassandraTemplate;
cassandraTemplate.insert(List<DomainClass>);
Follow-up Question...
@EnableAsync
public class GenericWriter<K, V> extends CacheWriterAdapter<K, V> implements Declarable {
private static Logger log = LoggerFactory.getLogger(GenericWriter.class);
@Autowired
private CassandraOperations cassandraOperations;
ExecutorService executor = null;
/**
* Cache Writer get called before any event occurs on the cache, where in
* EntryEvent interface reference has the helper methods
*/
@Override
@Async
public void beforeCreate(EntryEvent<K, V> e) throws CacheWriterException {
String eventOperation = e.getOperation().toString();
log.info("#####inside before create#####");
executor = Executors.newSingleThreadExecutor();
executor.submit(() -> {
log.info("****inside submit*****");
if (eventOperation.equals("CREATE")) {
log.info("Cache Writer for " + e.getRegion().getName() + " over Cassandra is activated"
+ e.getNewValue());
try {
cassandraOperations.insert(e.getNewValue());
} catch (CassandraConnectionFailureException | CassandraWriteTimeoutException
| CassandraInternalException cassException) {
cassException.printStackTrace();
log.info("Cassandra Exception:" + cassException.toString());
}
catch (Exception ex){
log.info("Exception--------------------"+ex.getStackTrace());
ex.printStackTrace();
}
}
});
executor.shutdown();
}
@Override
public void init(Properties arg0) {
// TODO Auto-generated method stub
}
}