Use of Cassandra TupleValue


(Normen Müller) #1

How to create a Cassandra TupleValue? Under https://docs.datastax.com/en/developer/java-driver/3.3/manual/tuples/ I found some code snippets, but I don’t know how to get cluster value.


(Renato) #2

Hi @normenmueller,

You first need to inject Lagom’s CassandraSession where you plain to use it.

Lagom’s CassandraSession has a underlying() method that will give you access to the underlying Datastax session. It will be wrapped in a CompletionStage. It will return a CompletionStage<Session> (Java) or Future[Session] (Scala).

Datastax Session has a getCluster() method that you can use, for instance:
(using java api)

// get this injected
CassandraSession session; 

// use it
session
  .underlying() // access underlying Datastax session 
  .thenApply(sess -> {
    Cluster cluster = sess.getCluster();
    // use session and cluster here 
    }
  );