Get Started with Astra Java SDK

Stargate and DataStax Astra DB are well-established 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. Here’s a 101 on these APIs and when to use them.

Part of our mission at DataStax is to make the power of open source easily accessible for every developer, so we built a software development kit (SDK) that wraps all the APIs in Astra and Stargate to simplify your experience using them.

For the uninitiated, an 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).

So far, 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.

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 that proudly provides 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. (If you haven’t already, register for a free Astra DB account to start experimenting.)
  • 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 fewer 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, isn’t it? To get started, check out our Astra SDK quickstart guide.

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

To get started with any of these services, check out our Spring integrations guide.

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

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

If you don’t already have the quickstart pages open in new tabs, we’ve listed them again in “Resources” at the end of this post. Give them a try, and if you get stuck at any point you can always jump into our official DataStax Developers discord to get help directly from Cassandra experts.

In the meantime, 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.

Follow DataStax on Medium for exclusive posts on all things open source, including Pulsar, Cassandra, streaming, Kubernetes, and more. To join a buzzing community of developers from around the world and stay in the data loop, follow DataStaxDevs on Twitter and LinkedIn.

This post was originally published on JaxEnter.

Resources

  1. Stargate SDK Quickstart
  2. Astra SDK Quickstart
  3. Spring Boot Starter QuickStart
  4. Astra SDK Reference Configuration
  5. Official Astra DevOps API documentation
  6. DataStax Astra DB | DataStax
  7. What is DataStax Astra Streaming?
  8. Stargate.io
  9. Free courses | DataStax Academy
  10. DataStax Developers YouTube channel

--

--

--

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

My first week of open source: how I got involved, and what I’ve learned

One day, you’re questioning what on earth will ever make you feel happy and fulfilled

AWS VPC tutorial: Spinning-up EC2 instances and setting traffic rules (part 2)

NET603 Week 9 — Progress Report

How to Fix That Pesky CORS Error

Polycom Trio (or any 3PIP device) cannot join Microsoft Teams meetings

Active Record Query Methods That Will Make Your Life Easier

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 Event-Driven Distributed Systems in Go with gRPC, NATS JetStream and CockroachDB

Design Considerations for Scaling WebSocket Server Horizontally With a Publish-Subscribe Pattern

Apache Kafka Architecture and how does it work

Refactoring and Optimizing a High Traffic API at PayPal