Connect Cadence to Astra DB in 5 Easy Steps

Cadence and Astra DB are a winning pair for developers looking to visualize their workflows while having a robust, easily-scalable database running in the background. Read on to learn how to connect Cadence to Astra DB in just 5 simple steps.

Cadence is a multi-tenant orchestration framework that helps with managing workflows. It scales horizontally to handle millions of concurrent executions from various customers. Cadence uses Docker Compose to run their server, and uses Apache CassandraⓇ as its default backend dependency. As a bonus, with Docker Compose you can also use Cadence with MySQL, PostgreSQL, Statsd+Graphite, and Elasticsearch.

In this post, we’ll show you how to connect Cadence with DataStax Astra DB to easily manage workflows at scale. This runbook is going to use DataStax cql-proxy, which is a sidecar designed to forward your application’s CQL traffic to an appropriate database service. (You may want to bookmark this one.)

Let’s get started!

Step 1: Setting up Astra DB

Before connecting to Temporal, you need to first create an Astra database instance and gather all your credentials. If you haven’t already, you can sign up for a free Astra DB account that will give you 80 GB monthly to work with. Now you can go ahead and spin up your first database with these steps:

  1. Create an Astra Database.
  • When asked for the keyspace name, name it temporal.
  • Once your database is created, navigate back to your database dashboard and click Add Keyspace.
  • Name this second keyspace temporal_visibility

The status of your database will temporarily go to Maintenance but a few seconds later you can refresh your screen and the status should switch to Active.

Figure 1. Screenshot of Astra DB dashboard and where to add the keyspaces.

2. Create an Astra Token.

Tokens are required to authenticate against Astra DB with APIs or drivers. These tokens can be used with multiple databases and can be configured to have specific permissions.

In this example, you’ll create a token using Admin Role. Temporal uses this token to receive credentials and permission to access your database, similar to how Cassandra has a “user” and “password”, which we’ll discuss in more detail in Step 4. When you create your tokens, download the CSV file to keep these credentials safe.

3. Find your Database ID.

Lastly, you want to get your Database ID. You can find this in one of two ways:

Step 2. Setting up Cadence

  1. First, clone this GitHub repository.
  2. Then, navigate to the cloned repository and use your preferred text editor (e.g. VisualStudio or Sublime) to update the .env file with the Astra Token and Astra Database ID that you obtained above.

Step 3. Migrating Cadence schema to Astra DB

Here, you’ll create and set up the keyspaces you made earlier in Astra DB with temporal-cassandra-tool. This tool is part of the Cadence repo and it relies on the schema definition.

  1. Navigate to your cloned cadence-astra-cql-proxy directory.
  2. Run the following commands to initialize the keyspaces that we created through Astra DB. Note that there are two sets of commands: one for cadence keyspace and one for cadence_visibility keyspace.

Once the process is complete, you should see a message similar to this:

Great! Your schemas have now been migrated with Astra DB. You can double-check the tables by querying your database in Astra DB’s CQL Console.

To do this, run a quick DESCRIBE tables; in both your cadence and cadence_visibility keyspaces, you should see there are tables loaded in that were created by the schema migration.

Figure 2. Screenshot of created tables in Astra DB’s CQL Console.

Step 4. Running Docker Compose

In this step, the docker-compose-cqlproxy.yaml file is already provided for you in the cassandra-astra-cql-proxy repo. This file creates different Docker containers to run Temporal server. The persistence layer is configured for you to connect with cql-proxy, and it should pull the Astra DB credentials you set up earlier.

Run the following command to start Cadence:

Step 5. Test and validate

Now you can test your connection and run some sample Cadence projects. Using Cadence’s Command Line tool, you can interact with your local Temporal server. Here’s how:

  1. Create a domain samples-domain by running the following command:

2. Clone the sample project repository to your machine. Navigate to this project and run make to build all the projects.

3. You can start by running the sample Hello World project by following the instructions in that repository.

Once you have this all up and running, you should be able to see your workflows on both the Cadence UI and Astra UI. You can see the domain on the top left is samples-domain, the domain we created, and the Status of each workflow shows as “Completed”.

Figure 3. Screenshot of completed workflows in the Cadence UI.

And just like that, you’ve spun up a free, serverless database with Astra DB and connected it to Cadence!

Conclusion

Cadence and Astra DB make a powerful pairing, and this five-step guide marks your first step in exploring the possibilities. With them, you can visualize your workflows with ease knowing you have a strong, supported database running in the background. So, keep this post handy and make the most out of your free Astra DB account by going ahead and experimenting with some Cadence samples!

Check out DataStax Devs YouTube channel for free tutorials and follow DataStaxDevs on Twitter and LinkedIn to join a buzzing community of developers from around the world.

Resources

  1. DataStax Astra DB
  2. Cadence Workflow
  3. A client-side CQL proxy/sidecar
  4. Easily Manage Workflows at Scale with Temporal.io and Astra DB
  5. Connect Temporal.io to Astra DB in 5 Easy Steps with CQL-Proxy
  6. How to Connect Temporal.io to Astra DB with Kubernetes

--

--

--

We’re huge believers in modern, cloud native technologies like Kubernetes; we are making Cassandra ready for millions of developers through simple APIs; and we are committed to delivering the industry’s first and only open, multi-cloud serverless database: DataStax Astra DB.

Recommended from Medium

Public methods in ruby (part 1/2)

Moving a Cloud Foundry app to Knative on IBM Cloud

Difference Between OOP And POP (Blog # 1)

Which backup solution should I choose: Rdiffweb or Minarca?

Speed vs productivity is the wrong argument to be having about languages.

Clustering in NodeJs — Performance Optimization - Part II

The Software Development Cycle and How It Burns You Out

Inside OutSystems Engineering —  Sandra Rodrigues, Quality Practice Lead

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
DataStax

DataStax

DataStax is the company behind the massively scalable, highly available, cloud-native NoSQL data platform built on Apache Cassandra®.

More from Medium

Building APIs to Interact with Data in a Cloud-Native Ecosystem

Architecture of object-based storage and S3 standard specifications

Moving all our Airflow Architecture to Kubernetes

First Anniversary Celebration of Apache DolphinScheduler’s Graduation From ASF Incubator!