Save DTO in Alpakka Cassandra

238 views Asked by At

Hi I create my own Connector of Cassandra using the datastax drivers. But I´m facing some Memory leaks issues, so I start considering another solutions like Alpakka de lightbend which has a Cassandra connector.

But after check the poor documentation I´m changing my mind, since it´s just using the connector with CQLSH queries, and in my case I manage DTO objects.

Anybody knows any documentation where I can see if Alpakka cassandra manage the save of DTO´s with consistency level?.

This code is from my current connector. I would like to achieve something similar.

private void updateCreateEntry(DTO originalDto, Mapper cassandraMapper) {
    ConsistencyLevel consistencyLevel = ((DTOCassandra) originalDto).getConsistencyLevel();
    //.- For writing we set the consistency level to quorum
    cassandraMapper.save(originalDto, Option.consistencyLevel(consistencyLevel != null ? consistencyLevel : DEFAULT_CONSISTENCY_LEVEL));
}
1

There are 1 answers

1
Stefano Bonetti On BEST ANSWER

As you've noticed, presently the Cassandra connector within Alpakka is quite thin. If you need a richer support for your DTO, you could choose a richer client like Phantom.

There are excellent examples on how to use Phantom - check this one out for instance. Once you have created you model, Phantom will give you a def store[T](t: T): Future[ResultSet] function to insert data.

You can feed calls to these function to a mapAsync(n) combinator to make use of them in your Akka Stream.