Skip to main content
NATS is an open-source messaging system for cloud-native applications. It provides a lightweight publish-subscribe architecture for high-performance messaging. NATS JetStream is a streaming data platform built on top of NATS. It enables real-time and historical access to streams of data via durable subscriptions and consumer groups.

Prerequisites

Before ingesting data from NATS JetStream into RisingWave, please ensure the following:
  • The NATS JetStream server is running and accessible from your RisingWave cluster.
  • If authentication is required for the NATS JetStream server, make sure you have the client username and password. The client user must have the subscribe permission for the subject.
  • Create the NATS subject from which you want to ingest data.
  • Ensure that your RisingWave cluster is running.

Ingest data into RisingWave

When creating a source, you can choose to persist the data from the source in RisingWave by using CREATE TABLE instead of CREATE SOURCE and specifying the connection settings and data format.

Syntax

schema_definition:
RisingWave performs primary key constraint checks on tables with connector settings but not on regular sources. If you need the checks to be performed, please create a table with connector settings.For a table with primary key constraints, if a new data record with an existing key comes in, the new record will overwrite the existing record.
According to the NATS documentation, stream names must adhere to subject naming rules as well as being friendly to the file system. Here are the recommended guidelines for stream names:
  • Use alphanumeric values.
  • Avoid spaces, tabs, periods (.), greater than (>) or asterisks (*).
  • Do not include path separators (forward slash or backward slash).
  • Keep the name length limited to 32 characters as the JetStream storage directories include the account, stream name, and consumer name.
  • Avoid using reserved file names like NUL or LPT1.
  • Be cautious of case sensitivity in file systems. To prevent collisions, ensure that stream or account names do not clash due to case differences. For example, Foo and foo would collide on Windows or macOS systems.

Parameters

Examples

The following SQL query creates a table that ingests data from a NATS JetStream source.
Stream creation security Starting in v2.5, RisingWave does not create NATS streams automatically by default (allow_create_stream = false). This prevents accidental stream creation in production environments due to typos or misconfigurations. To enable automatic stream creation, set allow_create_stream = 'true'. Only enable this in development environments or when you specifically want RisingWave to manage stream creation.
The parameters supported by the async_nats crate are all supported in the RisingWave NATS source connector.