Get Started with Astra Java SDK
Author: Cédrick Lunven
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).
- 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 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.
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 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.
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.
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.
Naturally, we built a Java SDK to give the developers using this popular framework a leg up. Here’s a look at the architecture:
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.