Getting Started with the DataStax Astra Java SDK

Share
  • March 10, 2022

Stargate and DataStax Astra DB are open source projects designed to make it easier than ever to interact with your cloud-native databases. Although to provide all the useful features developers need, these technologies bundle up several APIs that could make it overwhelming for newcomers to get started.

For the uninitiated, a Software Development Kit (SDK) is a set of software-building tools that streamline development for a specific platform. It includes building blocks, debuggers and, often, a framework or libraries so you don’t have to code from scratch.

Think of it this way: if you wanted to make a chocolate cake, using an SDK is like being handed a box of chocolate cake mix. Not using an SDK is more like being given the recipe and having to figure out the preparation yourself (with the help of online tutorials and too much caffeine).

We provide an SDK for Java, JavaScript, and Python. This post focuses on Java in particular, which consists of three libraries:

  • Stargate SDK
  • Astra SDK
  • Spring Boot SDK

This post will briefly go over each of them to give you a better understanding of what they are and when to use them. We’ll also pepper in useful resources so you can keep digging to learn more. That said, let’s kick things off with the library that complements one of our favorite open source projects: Stargate.

SEE ALSO: An introduction to JobRunr, a distributed background job scheduler

Stargate SDK

Stargate is an open source gateway that shields developers from the complexities of Apache Cassandra® so you can easily bridge your app’s data with your databases — no matter what format your data is in.

Now let’s get into the SDKs. The Stargate SDK embeds three useful components: HTTP, Cassandra-native drivers, and a gRPC client. Take a look at Figure 1 below for an overview of the architecture.

Figure 1. Stargate SDK architecture overview.

As a brief introduction, the Stargate SDK covers the following APIs:

  • REST API provides CRUD operations on top of Cassandra objects (tables, UDT, records)
  • Document API allows you to save and search JSON documents like a document-oriented noSQL database
  • GraphQL API makes it easy to modify and query your table data using GraphQL types, mutations, and queries
  • CQL API lets you use the same CQL syntax, tools, and native language drivers as with any Cassandra deployment
  • gRPC API is built on the Google RPC framework (hence the name “gRPC”) and enables you to call any microservice in any cloud using Java, Rust, Go, or Node.js

While Stargate is the official data API for DataStax Astra DB, you can use the SDK with either standalone Stargate installations or Stargate deployed in Astra. To start coding with Stargate SDK, follow the Stargate SDK quickstart guide.

Astra SDK

Astra is the cloud platform of DataStax providing two main services: Astra DB and Astra Streaming.

  • Astra DB is a database-as-a-service for Apache Cassandra that handles the complexities of installing, managing, and scaling it. With multi-cloud compatibility, one-click clusters, and the freedom of open source, Astra DB is the fastest, easiest, and most flexible way to build cloud-first apps on Cassandra.
  • Astra Streaming is a streaming-as-a-service platform powered by Apache Pulsar for cloud-native messaging and event streaming. It’s a natural fit with Astra DB, allowing you to build real-time data pipelines in and out of Astra DB instances.

Figure 2. Astra platform APIs.

As you can see, Astra exposes no less than eight APIs. But don’t get overwhelmed, because the Astra Java SDK helpfully wraps them all so you can easily leverage the APIs you need, when you need them.

Now let’s take a closer look at the architecture. In the figure below, you’ll notice that the Astra SDK not only handles Stargate APIs (CQL, HTTP, GraphQL, gRPC), but also adds HTTP clients for the DevOps APIs (databases, IAM, streaming). Plus, it sets up the connection with Apache Pulsar, which you need to interact with Astra Streaming.

Figure 3. Astra SDK architecture overview.

The Astra DevOps APIs are essentially REST APIs that perform the following functions:

  • DB interacts with Astra databases
  • IAM stands for Identity and Access Management (IAM), and interacts with the underlying platform user management (Roles, Users, Token, Access List)
  • STREAM interacts with Astra Streaming Pulsar instances

Quite the all-in-one cake mix, right?

Spring Boot SDK

Lastly, we have the integration with Spring. The Spring Framework provides a modular architecture so you can flexibly build a Java-based enterprise app that can run on any deployment platform.

Spring Boot is, of course, based on this framework and provides a quick start for building and running standalone, production-ready Spring applications with minimal configuration.

Naturally, we built a Java SDK to give the developers using this popular framework a leg up. Here’s a look at the architecture:

Figure 4. Spring Boot SDK architecture overview

Aside from the same APIs as in the previous SDKs, this one features integrations with some select Spring services:

  • Spring Boot Starter makes it simple to manage dependencies by providing over 30 dependency descriptors that you can add to your project
  • Spring Data Cassandra provides a familiar interface to bridge your Java code with Apache Cassandra (without dealing with CQL)
  • Spring Boot Actuator exposes metrics so you can monitor and manage your app

SEE ALSO: Evolving Java Runtimes for a Cloud-Centric World

Dig into Astra Java SDK – the official Astra SDK for Java

Now that you’re familiar with Java SDKs and their (many) APIs, you’re better equipped to choose the right one for your next Cassandra project.

We hope this post encourages you to get started with the Astra Java SDK so you can deploy in days, not weeks, and truly get the most out of your Cassandra-based applications.

The post Getting Started with the DataStax Astra Java SDK appeared first on JAXenter.

Source : JAXenter