0

In datastax driver we have api like

withTimestampGenerator(new AtomicMonotonicTimestampGenerator())

to enable the feature to setting timestamp per query at client side. How can we achieve same with spring data canssandra.

I am aware that i can use "USING TIMESTAMP value" in cql but is there something which spring data cassandra provide ? I dont find such api in CassandraClusterFactoryBean .

2 Answers 2

2

You are correct!

Unfortunately, it appears SD Cassandra is missing a configuration option on the CassandraCqlClusterFactoryBean class supporting the withTimestampGenerator(:TimestampGenerator) configuration setting with the DataStax Java driver Cluster.Builder API.

Equally unfortunate is there is no workaround (other than the USING TIMESTAMP in CQL) at the moment either.

It also appears the CassandraCqlClusterFactoryBean is missing configuration options for:

  1. Cluster.Builder.withAddressTranslator(:AddressTranslator)
  2. Cluster.Builder.withClusterName(:String)
  3. Cluster.Builder.withCodeRegistry(:CodecRegistry)
  4. Cluster.Builder.withMaxSchemaAgreementWaitSeconds(:int)
  5. Cluster.Builder.withSpeculativeExecutionPolicy(:SpeculativeExecutionPolicy)

Though, beware, the withTimestampGenerator(..) is only supported in version 3 of the DataStax Java Driver, which the next version (i.e. 1.5.0) of SD Cassandra will support...

This feature is only available with version V3 or above of the native protocol. With earlier versions, timestamps are always generated server-side, and setting a generator through this method will have no effect.

Sign up to request clarification or add additional context in comments.

2 Comments

NOTE: since the SD Cassandra API (i.e. CassandraCqlClusterFactoryBean) does not support these configuration options, neither will the SD Cassandra XML namespace configuration meta-data (obviously).
Thanks for the reply John. So for now i will use USING TIMESTAMP only then.
-1

The timestamp capability is available in SD 1.5.x, public void setTimestampGenerator(TimestampGenerator timestampGenerator) { this.timestampGenerator = timestampGenerator; }

https://github.com/spring-projects/spring-data-cassandra/blob/cc4625f492c256e5fa3cb6640d19b4e048b9542b/spring-data-cassandra/src/main/java/org/springframework/data/cql/config/CassandraCqlClusterFactoryBean.java.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.