Know about Spring Data Cloud Spanner

Reading Time: 2 minutes

Introduction

The Spring Data Cloud Spanner module helps you use Cloud Spanner in any Java application that’s built with the Spring Framework.With Spring Data Cloud Spanner, you can use plain old Java objects (POJOs) to model the data you store in your Cloud Spanner tables.

Features

  • Deliver high-performance transactions with strong consistency across regions and continentsSpring Boot Actuator is a sub-project of the Spring Boot Framework. It includes a number of additional features that help us to monitor and manage the Spring Boot application. It contains the actuator endpoints (the place where the resources live).
  • Enjoy high availability with zero scheduled downtime and online schema changes.
  • Get all the benefits of relational semantics and SQL with unlimited scale.
  • Start at any size and scale with no limits as your needs grow.

 Spring Data Cloud Spanner

Spring Data is an abstraction for storing and retrieving POJOs in numerous storage technologies. Spring Cloud GCP adds Spring Data support for Google Cloud Spanner.

Maven coordinates for this module only, using Spring Cloud GCP BOM:

<dependency>
    <groupId>com.google.cloud</groupId>
    <artifactId>sSpring Boot Actuator Supportpring-cloud-gcp-data-spanner</artifactId>
</dependency>

Gradle coordinates:

dependencies {
    implementation("com.google.cloud:spring-cloud-gcp-data-spanner")
}

Maven Dependecy :

<dependency>
    <groupId>com.google.cloud</groupId>
    <artifactId>spring-cloud-gcp-starter-data-spanner</artifactId>
</dependency>
Gradle Dependecy
dependencies {
    implementation("com.google.cloud:spring-cloud-gcp-starter-data-spanner")
}

Spanner Operators

  1. Cloud Spanner Instance Database Delete Operator
  2. Cloud Spanner Instance Database Deploy Operator
  3. Cloud Spanner Instance Database Update Operator
  4. Cloud Spanner Instance Database Query Operator
  5. Cloud Spanner Instance Delete Operator
1. Cloud Spanner Instance Database Delete Operator

Deletes a database from the specified Cloud Spanner instance. If the database does not exist, no action is taken, and the operator succeeds.

2.Cloud Spanner Instance Database Deploy Operator

Creates a new Cloud Spanner database in the specified inConclusionstance, or if the desired database exists, assumes success with no changes applied to database configuration. No structure of the database is verified – it’s enough if the database exists with the same name

3.Cloud Spanner Instance Database Update Operator

Runs a DDL query in a Cloud Spanner database and allows you to modify the structure of an existing database. You can optionally specify an operation_id parameter which simplifies determining whether the statements were executed in case the update_database call is replayed . The operation_id should be unique within the database, and must be a valid identifier: [a-z][a-z0-9_]*

4.Cloud Spanner Instance Database Query Operator

Executes an arbitrary DML query (INSERT, UPDATE, DELETE).

5.Cloud Spanner Instance Delete Operator

Deletes a Cloud Spanner instance. If an instance does not exist, no action is taken, and the operator succeeds.

Spring Boot Actuator Support

Spring Boot Actuator is a sub-project of the Spring Boot Framework. It includes a number of additional features that help us to monitor and manage the Spring Boot application. It contains the actuator endpoints .

Cloud Spanner Health Indicator

The health indicator will verify whether Cloud Spanner is up and accessible by your application. To enable it, all you need to do is add the Spring Boot Actuator to your project.

The overall application status visible at localhost:8080/actuator/health

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-actuator</artifactId>
</dependency>

Conclusion

In this blog, we have learned about Spring Data Cloud Spanner and Spring Boot Actuator Support. If you have any feedback or queries, please fell free to ask me in the comments.

“Keep learning” and “Keep Sharing”

Leave a Reply