/cloud-spanner-connector

Primary LanguageJavaApache License 2.0Apache-2.0

Cloud Spanner Connector

A custom Camunda outbound connector to perform database operations in Cloud Spanner Database.

Supported Operations

Operation Description
Create Table This operation creates a new table in the given database.
Insert Data This operation will insert data in the given table of the specified database.
Update Data This operation is to update the data in a table based on where condition
Delete Data This operation is used to delete a data in a table based on where condition
Retrieve Data This operation will retrieve data from the spanner database. It also supports features like Limit, Sort and Filters.

Prereqisites

{
    "type": "service_account",
    "project_id": "",
    "private_key_id": "",
    "private_key": "-----BEGIN PRIVATE KEY-----\n ...\n-----END PRIVATE KEY-----\n",
    "client_email": "",
    "client_id": "",
    "auth_uri": "",
    "token_uri": "",
    "auth_provider_x509_cert_url": "",
    "client_x509_cert_url": "",
    "universe_domain": "googleapis.com"
  }
  

Connector Runtime

Build a jar file with dependencies

mvn clean package

Build an image by using the Dockerfile

FROM camunda/connectors:0.21.3

COPY target/spanner-connector-jar-with-dependencies.jar /opt/app/

ENTRYPOINT ["/start.sh"]

Command for BUilding an Image

docker build -t spannerconnector:latest .

Docker Compose

  • In this scenario, We are utilizing the self-managed version of Camunda 8, and we have created a corresponding Docker Compose file.

  • A Docker volume is utilized to establish a connection between local storage and the container.

  • Ensure that the local storage you're mounting includes the necessary JSON credential file.

  • You can utilize the docker-compose.yaml file to start a local connector runtime.

Element Template

The element templates can be found in the spanner-connector.json file.

Spanner Connection

Spanner Connection details must be filled for all the operations to establish a connection between the connector and the spanner database of the user.

spanner_connection.PNG

Spanner operations

These are the operations provided to do in Spanner database

spanner_operations.png

Create Table

spanner_create.PNG

Columns List SampleJSON

[
  {
    "colName": "bookId",
    "dataType": "INT64"
  },
   {
    "colName": "bookName",
    "dataType": "STRING(100)"
  },
   {
    "colName": "author",
    "dataType": "STRING(100)"
  }
  
]

Insert Data

spanner_insert.PNG

Data to be inserted SampleJSON

[
  {
    "bookId": 1,
    "bookName": "\"Two States\"",
    "author": "\"Chetan Bhagat\""
  }
]

*Note: you can insert upto two data in a single instance.

[
  {
    "bookId": 1,
    "bookName": "\"Two States\"",
    "author": "\"Chetan Bhagat\""
  },
  {
    "bookId": 2,
    "bookName": "\"Harry Potter\"",
    "author": "\"J K Rowling\""
  }
]

Update data

spanner_update.PNG

Delete data

spanner_delete.PNG

Retrieve data

spanner_retrieve.PNG

Note

  • Columns to display: If "All" is selected, all the columns will be retrieved. If "Selected Columns" is selected, then only the selected columns will be retrieved

Cloud Spanner Connector Resources

Content Link
YouTube Video Acheron's Camunda Connector for GCP Cloud Spanner - Create Table: A Developer's Walkthrough
Blog Post GCP Cloud Spanner Connector for Camunda 8

Contact Information

For any queries and further support, please drop us a mail at camunda.support@acheron-tech.com