Skip to content
Bluetape4k docs1.11

Configuration and object ownership

Latest stable Based on Bluetape4k release 1.11.0

Despite spring-boot in its name, the 1.11.0 source has no auto-configuration class, AutoConfiguration.imports, @ConfigurationProperties, or main resources. Adding the artifact to the classpath does not create a bean or a property namespace.

The module provides extensions for Spring Data Cassandra objects that already exist. Spring Boot or application configuration must supply:

  • CqlSession and ReactiveSession
  • CassandraOperations, ReactiveCassandraOperations, and AsyncCassandraOperations
  • CqlOperations, ReactiveCqlOperations, and AsyncCqlOperations
  • the mapping context, converters, and repository infrastructure

ReactiveSession.executeSuspending and prepareSuspending only call execute or prepare on their receiver. They neither create nor close a session and do not change contact points, local datacenter, keyspace, authentication, or driver profiles.

@Configuration(proxyBeanMethods = false)
class CassandraConfiguration : AbstractReactiveCassandraConfiguration() {
override fun getKeyspaceName(): String = "app"
override fun getLocalDataCenter(): String = "datacenter1"
}

Supply real values through environment-specific Spring Boot settings or a secret store. CqlSession is a thread-safe owner of connection pools and executors, so do not create one per service or request. When Spring creates the session, leave its closure to the Spring lifecycle.

Entity mapping, lifecycle callbacks, optimistic locking, and repository query derivation belong to Spring Data Cassandra. Driver codecs, prepared statements, consistency, and execution profiles belong to the DataStax driver. The bluetape4k adapters await those results or expose them as Flow.

bluetape4k-cassandra adds driver-level APIs. If the application does not need Spring Data mapping, that module plus CqlSession is simpler. If it needs repositories and converters, retain the Spring Data boundary in this module.

SituationPreferred entry point
Repository-centered CRUDSpring Data repository, with template coroutine adapters where needed
Dynamic Query with entity mappingReactiveCassandraOperations or AsyncCassandraOperations
Row-by-row streamingreactive operations plus Flow
Direct control over driver statements and pagingbluetape4k-cassandra plus driver APIs
Application schema migrationa dedicated migration process, not SchemaGenerator as a replacement

Mixing repositories, reactive templates, async templates, and raw sessions in one service obscures failure and transaction boundaries. Pick the required level first and descend to raw APIs only at an explicit edge.

AbstractCassandraTestConfiguration and its reactive peer override getRequiredSession() to return a companion-object shared session. Creating a session for each Spring application context quickly accumulates connections to the Testcontainers Cassandra instance. The same evidence supports managing a session as a long-lived object in production.

After configuration, read Reactive operations and coroutines for subscription and empty-result contracts. For hand-written CQL, continue with Async and low-level CQL operations.