Note that there are some explanatory texts on larger screens.

plurals
  1. POBe notified when Cassandra write operation completed in Akka
    primarykey
    data
    text
    <p>In <a href="http://www.cakesolutions.net/teamblogs/2013/07/31/akka-cassandra-activator/" rel="nofollow">this Akka and Cassandra tutorial</a>, an <a href="https://github.com/eigengo/activator-akka-cassandra/blob/master/src/test/scala/core/TweetActorsSpec.scala#L21" rel="nofollow">integration test that writes to Cassandra and expects to read back the same data</a> inserts a 1 second delay between the write and the read. The delay allows time for the write request to be transmitted over the network and processed on the server. This is necessary because the <a href="https://github.com/eigengo/activator-akka-cassandra/blob/master/src/main/scala/core/tweetwrite.scala#L13" rel="nofollow">application calls <code>session.executeAsync</code></a> to send a request to Cassandra, and proceeds without handling the response from Cassandra:</p> <pre><code>class TweetWriterActor(cluster: Cluster) extends Actor { val session = cluster.connect(Keyspaces.akkaCassandra) val preparedStatement = session.prepare("INSERT INTO tweets(key, user_user, text, createdat) VALUES (?, ?, ?, ?);") def saveTweet(tweet: Tweet): Unit = session.executeAsync(preparedStatement.bind(tweet.id.id, tweet.user.user, tweet.text.text, tweet.createdAt)) def receive: Receive = { case tweets: List[Tweet] =&gt; tweets.foreach(saveTweet) case tweet: Tweet =&gt; saveTweet(tweet) } } </code></pre> <p>Completing a write request usually takes much less time than 1 second, so the test can run faster if it instead receives a notification the write completed before attempting to read. How would you change the code to do this, while sticking to non-blocking I/O operations?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload