Hi,
I am using Cassandra to store my events so I have installed it locally and I gave necessary information in application.conf file and it is working fine.
When I go for a release I am restricted to use our own Cassandra. It has our own wrapper class to connect and query with the db.
How can I achieve this because we are just giving IP and port there is no option to pass our connection object.
Do we have any method to overridde, so that I can use our wrapper and connect.
Thanks
TimMoore
(Tim Moore)
September 3, 2019, 6:40am
2
Yes, you can customize the SessionProvider
class to add your own custom logic.
See the configuration for how to set this:
# The implementation of akka.cassandra.session.SessionProvider
# is used for creating the Cassandra Session. By default the
# the ConfigSessionProvider is building the Cluster from configuration properties
# but it is possible to replace the implementation of the SessionProvider
# to reuse another session or override the Cluster builder with other
# settings.
# For example, it is possible to lookup the contact points of the Cassandra cluster
# asynchronously instead of giving them in the configuration in a subclass of
# ConfigSessionProvider and overriding the lookupContactPoints method.
# It may optionally have a constructor with an ActorSystem and Config parameter.
# The config parameter is this config section of the plugin.
session-provider = akka.persistence.cassandra.ConfigSessionProvider
…and the SessionProvider
trait you can implement:
/*
* Copyright (C) 2016-2017 Lightbend Inc. <https://www.lightbend.com>
*/
package akka.cassandra.session
import akka.actor.{ ActorSystem, ExtendedActorSystem }
import com.datastax.driver.core.Session
import com.typesafe.config.Config
import scala.collection.immutable
import scala.concurrent.{ ExecutionContext, Future }
import scala.util.Failure
/**
* The implementation of the `SessionProvider` is used for creating the
* Cassandra Session. By default the [[ConfigSessionProvider]] is building
* the Cluster from configuration properties but it is possible to
* replace the implementation of the SessionProvider to reuse another
* session or override the Cluster builder with other settings.
This file has been truncated. show original
…and the default ConfigSessionProvider
implementation you can extend: