{"id":15056890,"url":"https://github.com/pingidentity/cassandra-spring-boot-starter","last_synced_at":"2025-05-16T16:30:46.003Z","repository":{"id":42160349,"uuid":"161685301","full_name":"pingidentity/cassandra-spring-boot-starter","owner":"pingidentity","description":"Cassandra spring-boot starter and auto configuration for pure datastax driver","archived":false,"fork":false,"pushed_at":"2023-04-07T07:55:10.000Z","size":64,"stargazers_count":2,"open_issues_count":0,"forks_count":5,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-04-04T03:51:07.064Z","etag":null,"topics":["cassandra","datastax","java","spring-boot","starter"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/pingidentity.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-12-13T19:25:44.000Z","updated_at":"2023-03-22T03:40:12.000Z","dependencies_parsed_at":"2024-11-19T22:52:13.460Z","dependency_job_id":null,"html_url":"https://github.com/pingidentity/cassandra-spring-boot-starter","commit_stats":{"total_commits":53,"total_committers":2,"mean_commits":26.5,"dds":"0.018867924528301883","last_synced_commit":"f437910cdd0ebed3dadaac74255abe6d0c6ae09c"},"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pingidentity%2Fcassandra-spring-boot-starter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pingidentity%2Fcassandra-spring-boot-starter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pingidentity%2Fcassandra-spring-boot-starter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pingidentity%2Fcassandra-spring-boot-starter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pingidentity","download_url":"https://codeload.github.com/pingidentity/cassandra-spring-boot-starter/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254567253,"owners_count":22092738,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cassandra","datastax","java","spring-boot","starter"],"created_at":"2024-09-24T21:57:49.251Z","updated_at":"2025-05-16T16:30:45.661Z","avatar_url":"https://github.com/pingidentity.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Cassandra spring-boot starter\nProvides pure cassandra datastax driver spring-boot autoconfiguration with optional health check.\nEasy cassandra getting started experience without spring-data complexity or if you prefer to be closer to driver level.\nDeclarative configuration for all supported datastax driver options and automatic spring bindings for mappers and query accessors.\n\n\n## Note about versioning\ncassandra spring-boot starter versions are aligned with spring-boot versions to guarantee compatibility.\nIf you using spring-boot v2.1.x stick with v2.1.x cassandra starter version. (v1.5.x for spring-boot v1.5.x, e.t.c.)\n\nWe trying to support latest cassandra driver versions as they released.\n\n## Getting started\nReference library from maven central:\n```xml\n\u003cdependency\u003e\n    \u003cgroupId\u003ecom.pingidentity.oss.cassandra4j\u003c/groupId\u003e\n    \u003cartifactId\u003espring-boot-cassandra-starter\u003c/artifactId\u003e\n    \u003cversion\u003e2.1.0\u003c/version\u003e\n\u003c/dependency\u003e\n```\n\nFor cassandra running on localhost add following to your spring-boot `application.properties`:\n```Java Properties\ncassandra.contact-points=127.0.0.1\ncassandra.keyspace-name=my_app_keyspace\n```\n\nInject driver session and query data:\n```Java\n@Autowired\nprivate Session session;\n\n// somewhere in the code\n\nResultSet rs = session.execute(\"select release_version from system.local\");\n\n// work your magic\n\n```\n\n## Registered beans\nAuto configration makes following beans avaliable for autowiring anywhere:\n\n- `cluster` (com.datastax.driver.core.Cluster), fully initialized instance, singleton.\n- `session` (com.datastax.driver.core.Session), connected session, ready to execute queries, singleton.\n- `mappingManager` (com.datastax.driver.mapping.MappingManager), object mapper associated with session.\n\n## Auto-binding of mappers \u0026 accessors\nCassandra auto configuration provides special support for datastax object mapper.\nWhen enabled it can discover and automatically register bean mappers and accessors with spring context.\n\nFirst, let configuration know where your pojo and accessors resides: \n\n```Java Properties\ncassandra.scan-packages=io.gitub.yourapp.model\n```\n\nAuto configuration will look for `@Table` and `@Accessor` annotated classes:\n\n```Java\n@Table\npublic class Video {...}\n\n@Accessor\npublic interface VideoQueries {...}\n```\n\nand register corresponding `Mapper\u003cVideo\u003e` and `VideoQueries` implementations with spring. \nThose can be simply injected and used in your code with no extra coding:\n\n```Java\n@Autowired\nprivate Mapper\u003cVideo\u003e videoMapper;\n\n@Autowired\nprivate VideoQueries videoQueries;\n```\t\t\n\n## Health check\nCassandra auto configuration provides spring-boot health indicator with id `cassandra` for probing cluster connection.\nAutomatically enabled when spring-boot-starter-actuator dependency is present. Can be controlled normal way with `management.health.cassandra.enabled` property.\n\n## Configuration\n\n### Connection info\n`cassandra.contact-points` - required. Comma separated list of initial contact points (ip addresses or host names)  \n`cassandra.keyspace-name` - Required. Keyspace name to use for connecting session.  \n`cassandra.cluster-name` -  Optional name of the cluster.  \n`cassandra.port` - Port to connect to (9042 if omitted).   \n`cassandra.protocol-version` - \t (auto discovery will be used when ommited).  \n`cassandra.allow-beta-protocol-version` - use latest development protocol version.     \n`cassandra.ssl` - when set to `true` will enable ssl for connection, using JDK-based  implementation with the default options. \nIf you need more control over ssl engine please refer to [Customization section](#customizing).  \n`cassandra.no-compact` - enables `NO_COMPACT` option.   \n`cassandra.max-schema-agreement-wait-seconds` - maximum time to wait for schema agreement before returning from a DDL query in seconds.  \n`cassandra.address-translator` - address translator, supported options: *IDENTITY* (default) | *EC2* (EC2MultiRegionAddressTranslator)\n\n### Socket options\n`cassandra.socket.connect-timeout` - connection timeout in ms.  \n`cassandra.socket.keep-alive` - TCP connection keep alive.  \n`cassandra.socket.read-timeout` - per host read timeout in ms.  \n`cassandra.socket.receive-buffer-size` - size of incoming network IO buffer in bytes.  \n`cassandra.socket.send-buffer-size` - size of outgoing network IO buffer in bytes.  \n`cassandra.socket.so-linger` - linger-on-close timeout.  \n`cassandra.socket.reuse-address` - whether to enable address reuse.  \n`cassandra.socket.tcp-no-delay` - TCP no delay (Nagle).  \n\n### Connection pooling options\n`cassandra.pool.heartbeat-interval-seconds` - heartbeat interval in seconds.  \n`cassandra.pool.idle-timeout-seconds` - idle connection timeout in seconds.  \n`cassandra.pool.pool-timeout-millis` - timeout for acquiring connection from pool in ms.  \n\n`cassandra.pool.local.core-connections-per-host` - initial number of connections to each \"local\" host.  \n`cassandra.pool.local.max-connections-per-host` - max number of connections to each \"local\" host.  \n`cassandra.pool.local.max-requests-per-connection` - max number of requests per connections to \"local\" host.  \n`cassandra.pool.local.new-connection-threshold` - threshold to trigger new connection to \"local\" host.  \n\n`cassandra.pool.remote.core-connections-per-host` - initial number of connections to each \"remote\" host.  \n`cassandra.pool.remote.max-connections-per-host` - max number of connections to each \"remote\" host.  \n`cassandra.pool.remote.max-requests-per-connection` - max number of requests per connections to \"remote\" host.  \n`cassandra.pool.remote.new-connection-threshold` - threshold to trigger new connection to \"remote\" host.  \n\n### Compression\n`cassandra.compression` Transport compression. Supported options *NONE* | *SNAPPY* | *LZ4*\n\n### Authentication\n`cassandra.auth.username` - Username to connect to cassandra host.  \n`cassandra.auth.password` - Password to connect to cassandra host.  \n\nPlease see Customizing section if you want to use custom `AuthProvider`.\n\n### Load balancing \n`cassandra.load-balancing-policy` - Load balancing policy to use with a cluster. Supported options: \n - *ROUND_ROBIN* - for round robin load balancing.\n - *DC_AWARE* for datacenter aware round robin load balancing. \n\n#### Datacenter aware load balancing\n`cassandra.dcaware.local-dc` - name of the \"local\" datacenter.  \n`cassandra.dcaware.used-hosts-per-remote-dc` - Number of hosts per remote datacenter to consider.  \n`cassandra.dcaware.allow-remote-dcs-for-local-consistency-level` - Allows the policy to return remote hosts for query plans with LOCAL_* consistency levels.  \n\n#### Token aware load balancing\n`cassandra.tokenaware.enabled` - set to true to use token awareness for primary load balancing policy\n`cassandra.tokenaware.replica-ordering` - replica ordering strategy (*TOPOLOGICAL* | *RANDOM* | *NEUTRAL*) (RANDOM when ommited).  \n\n#### Latency aware load balancing\n`cassandra.latencyaware.scale` - scale in ms.  \n`cassandra.latencyaware.retry-period` - retry period in ms.  \n`cassandra.latencyaware.minimum-measurements` - minimum number of measurements per-host to consider.  \n`cassandra.latencyaware.exclusion-threshold` - exclusion threshold.  \n`cassandra.latencyaware.update-rate` - update rate in ms.  \n\n\n### Query retries options\n`cassandra.retry.policy` - retry policy, supported options: *DEFAULT* | *FALLTHROUGH*. \n`cassandra.retry.logging-enabled` - enable retry decision logging. \n\n### Reconnection options\n`cassandra.reconnection.policy` - reconnection policy, supported options *CONSTANT* | *EXPONENTIAL*.  \n\n`cassandra.reconnection.constant-delay` - delay between reconnection attempts in ms for *CONSTANT* policy.  \n\n`cassandra.reconnection.exponential-base-delay` - base delay in ms for *EXPONENTIAL* policy.  \n`cassandra.reconnection.exponential-max-delay` - max delay in ms for *EXPONENTIAL* policy.  \n\n### Timestamp generation options\n`cassandra.timestamp-generator` - client-side generator that will produce the timestamp sent with each query: \n - *ATOMIC* - (default) monotonically increasing timestamps among all client threads\n - *THREAD_LOCAL* - monotonically increasing timestamps on per thread basis\n - *SERVER_SIDE* - let cassandra node assign server-side timestamp. \n\n`cassandra.atomic.warning-interval-sec` - how often drift warning logged in seconds for *ATOMIC* generator.  \n`cassandra.atomic.warning-threshold-sec` - timestamps drift allowed before a warning in seconds for *ATOMIC* generator.  \n\n`cassandra.thread-local.warning-interval-sec` - how often drift warning logged in seconds for *THREAD_LOCAL* generator.  \n`cassandra.thread-local.warning-threshold-sec` - timestamps drift allowed before a warning in seconds for *THREAD_LOCAL* generator.  \n\n### Speculative execution options\n`cassandra.speculative-execution` - speculative query execution policy, possible options:\n - *NONE* - (default) no speculative execution\n - *CONSTANT* - speculative execution with fixed delay\n - *PERCENTILE* - speculative execution with latency percentile threshold, based on recent statistics, cluster wide or per host   \n \n`cassandra.constant-execution.constant-delay-millis` - constant execution delay in millis.  \n`cassandra.constant-execution.max-speculative-executions` - cap on total executions for constant strategy.   \n\n`cassandra.percentile-execution.max-speculative-executions` - cap on total executions for percentile strategy.  \n`cassandra.percentile-execution.percentile` - the percentile that a request's latency must fall into to be considered slow.  \n\n`cassandra.percentile-execution.cluster-wide.highest-trackable-latency-ms` - highest latency to be tracked in ms for cluster wide stats.  \n`cassandra.percentile-execution.cluster-wide.interval-ms` - sample interval for cluster wide stats.  \n`cassandra.percentile-execution.cluster-wide.min-recorded-values` - minimum number of recorded values to consider sample for cluster wide stats.  \n`cassandra.percentile-execution.cluster-wide.number-of-significant-value-digits` - number of significant decimal digits to maintain histogram resolution for cluster wide stats.  \n\n`cassandra.percentile-execution.per-host.highest-trackable-latency-ms` - highest latency to be tracked in ms for host stats.  \n`cassandra.percentile-execution.per-host.interval-ms` - sample interval for host stats.  \n`cassandra.percentile-execution.per-host.min-recorded-values` - minimum number of recorded values to consider sample for host stats.  \n`cassandra.percentile-execution.per-host.number-of-significant-value-digits` - number of significant decimal digits to maintain histogram resolution for host wide stats.  \n\n### Query options\n`cassandra.query.consistency-level` - default consistency level for queries.  \n`cassandra.query.fetch-size` - default fetch size for SELECT queries.  \n`cassandra.query.serial-consistency-level` - default serial consistency level to use for queries.  \n`cassandra.query.default-idempotence` - default idempotence for queries.  \n`cassandra.query.prepare-on-all-hosts` - whether the driver should prepare statements on all hosts in the cluster.  \n`cassandra.query.reprepare-on-up` - whether the driver should re-prepare all cached prepared statements on a host when it's back up.  \n`cassandra.query.metadata-enabled` - whether client-side token and schema metadata enabled.  \n`cassandra.query.refresh-schema-interval-ms` - default schema refresh interval in ms.  \n`cassandra.query.max-pending-refresh-schema-requests` - cap schema refresh requests for control connection.  \n`cassandra.query.refresh-node-list-interval-ms` - default node list refresh interval in ms.  \n`cassandra.query.max-pending-refresh-node-list-requests` - cap node list refresh requests for control connection.  \n`cassandra.query.refresh-node-interval-ms` - default node refresh interval in ms.  \n`cassandra.query.max-pending-refresh-node-requests` - cap node refresh requests for control connection.  \n\n### Metrics options\n`cassandra.metrics-enabled` - enables/disables metrics collection for cluster, enabled by default.  \n`cassandra.jmx-reporting-enabled` - enables/disables metrics reporting over JMX, enabled by default.\n\n### Misc options\n`cassandra.scan-packages` - comma separated list of package to scan for mappers and accessors. See [auto binding section](#auto-binding-of-mappers--accessors) for detailed information.\n\n## Customizing \nWhen properties is not enough cassandra auto configuration provides a way for programmatic customization of cluster configuration.\nThere are two customization interfaces avaliable:\n - `com.pingidentity.cassandra4j.CassandraConfigurationCustomizer` called before cluster instance is constructed and initialized, `Cluster.Builder` instance passed as argumet after all declarative configuration was applied.  \n - `com.pingidentity.cassandra4j.CassandraPostConfigurationCustomizer` called right after cluster instance is constructed. Fully initialized \u0026 connected `Cluster` instance is passed as argument.  \n \nDefine a corresponding beans that implements interfaces above in your spring context and they will be automatically applied.\n\nFor instance if you want custom address translator or auth provider you'd go with `CassandraConfigurationCustomizer`:\n\n```Java\n@Bean\npublic CassandraConfigurationCustomizer authCustomizer()\n{\n    return builder -\u003e builder.withAuthProvider(new GSSAPIAuthProvider());\n}\n```\n\nIf you want to register extra codecs for your application your choice is `CassandraPostConfigurationCustomizer`:\n\n```Java\n@Bean\npublic CassandraConfigurationCustomizer codecCustomizer()\n{\n    return cluster -\u003e\n    {\n        //custom enum codec\n        cluster.getConfiguration().getCodecRegistry().register(new EnumNameCodec\u003c\u003e(Video.Genre.class));\n        \n        //codec to handle java.time.Instant type\n        cluster.getConfiguration().getCodecRegistry().register(InstantCodec.instance);\n\n        return cluster;\n    };\n}\n```\n\nYou can define several customizers beans of both types in your application as well, they will be applied in order.\n\n## Docs \u0026 Examples\nFull blown microservice example can be found under [example](example) folder. It implements small\nREST API backed by cassandra auto configuration. \n\nRefer to corresponding README for information how to run it.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpingidentity%2Fcassandra-spring-boot-starter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpingidentity%2Fcassandra-spring-boot-starter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpingidentity%2Fcassandra-spring-boot-starter/lists"}