For the complete documentation index, see llms.txt. This page is also available as Markdown.

Data Streaming

Load large volumes of data into a GridGain 9 cluster with the Data Streamer API, configure batching and flushing, use receivers, and track failed entries.

Data streaming provides a fast, efficient method for loading, organizing, and distributing large volumes of data across your cluster. Data streamer accepts a stream of data and distributes data entries across the cluster, where the processing takes place. Data streaming is available in all table views.

Diagram of a data streamer distributing data entries across cluster nodes for processing

Data streaming provides at-least-once delivery guarantee.

The Java examples on this page use the thin client, which requires the ignite-client module. For repository and dependency configuration, see Project Setup and Required Modules.

Using Data Streamer API

The Data Streamer API lets you load large amounts of data into your cluster quickly and reliably using a publisher–subscriber model, where you create a publisher that streams your data entries to a table view, and the system distributes these entries across the cluster. You can configure how the data is processed via a DataStreamerOptions object that allows to set batch sizes, auto-flush intervals, retry limits.

Configuring Data Streamer

DataStreamerOptions lets you fine-tune how data is streamed into your cluster by setting parameters for batching, retries, parallelism, and auto-flush timing:

  • pageSize: Specifies the number of entries to process in each page or chunk of data.

  • perPartitionParallelOperations: Determines the number of parallel operations allowed on each partition.

  • autoFlushInterval: Defines the time interval (in milliseconds) after which the system automatically flushes any incomplete buffers.

  • retryLimit: Specifies the maximum number of retry attempts for a failed data submission before giving up.

  • sameKeyUpdateMode: Controls how multiple updates to the same key within a single batch are handled, which determines how many continuous query events those updates produce. Defaults to SQUASH. See Same-Key Update Mode.

Same-Key Update Mode

By default, the data streamer applies each batch as a single implicit transaction with one commit timestamp. When a batch contains several updates to the same key, those updates are conflated: only the final state of the key is stored, and a continuous query observes a single event for that key. The sameKeyUpdateMode option controls this behavior:

  • SQUASH (default): Multiple updates to the same key within one batch are conflated to the final state. A continuous query observes one event per affected key per batch, carrying the final value. For a key that did not exist before the batch, this is a single CREATED event. This is the most performant mode and is recommended when only the final state matters.

  • PRESERVE: Same-key updates within one batch are detected and the batch is split so that each update lands in a separate transaction with its own commit timestamp. A continuous query observes one event per update, each carrying that update's value. For a new key, the first event is CREATED and the subsequent same-key events are UPDATED. This mode is more expensive than SQUASH, because each same-key collision triggers an additional implicit transaction.

Updates to different keys can still share the same implicit transaction and commit timestamp regardless of the mode.

Use PRESERVE when a continuous query subscriber must observe every intermediate update to a key — for example, when the data streamer feeds an event pipeline that reacts to each individual change.

Streaming Data

Before data is streamed to the cluster, each entry must be wrapped in an instance of the DataStreamerItem<T> class. This wrapper allows you to perform PUT and REMOVE operations with data:

  • Use DataStreamerItem.of(entry) to insert new entries into the table.

  • Use DataStreamerItem.removed(entry) to delete existing ones.

Wrapped data then can be passed to a publisher and streamed to the table.

The example below demonstrates how to use RecordView, create a publisher, configure the data streamer, insert account records into the existing accounts table and then delete them:

Streaming with Receiver

The GridGain 9 streaming API supports advanced streaming scenarios by allowing you to create a custom receiver that defines server-side processing logic. Use a receiver when you need to process or transform data on the server, update multiple tables from a single data stream, or work with incoming data that does not match a table schema.

With a receiver, you can stream data in any format, as it is schema-agnostic. The receiver also has access to the full GridGain 9 API through the DataStreamerReceiverContext.

The data streamer controls data flow by requesting items only when partition buffers have space. DataStreamerOptions.perPartitionParallelOperations controls how many buffers can be allocated per partition. When buffers are full, the streamer stops requesting more data until some items are processed. Additionally, if a resultSubscriber is specified, it also applies backpressure on the streamer. If the subscriber is slow at consuming results, the streamer reduces its request rate from the publisher accordingly.

Receivers written in .NET can write to the server node log through IDataStreamerReceiverContext.LoggerFactory, which exposes the standard Microsoft.Extensions.Logging.ILoggerFactory. Messages are forwarded to the node executing the receiver and appear in its node log under the category name passed to CreateLogger. See Logging from .NET Compute Jobs for details and examples.

To use a receiver, you need to implement the DataStreamerReceiver interface. The receiver's receive method processes each batch of items streamed to the server, so you can apply custom logic and return results for each item as needed:

  • page: The current batch of data items to process.

  • ctx: The receiver context, which lets you interact with GridGain 9 API.

  • arg: An optional argument that can be used to pass custom parameters to your receiver logic.

Examples

Updating Multiple Tables

The following example demonstrates how to implement a receiver that processes data containing customer and address information, and updates two separate tables on the server:

1. First, create the custom receiver that will extract data from the provided source and write it into two separate tables: customers and addresses.

2. Create a descriptor that refers to your receiver implementation. This descriptor will be passed later to a SubmissionPublisher when streaming data.

3. Next, obtain the target table to partition the data for streaming. In this example we partition by customerId to ensure the receiver is colocated with the customer data, enabling local upserts. Then define how to extract keys and payloads from the source, and stream the data using a SubmissionPublisher.

Distributed Computations

You can also use a streamer with a receiver to perform distributed computations, such as per-item calculations and map-reduce tasks on the returned results.

This example demonstrates a simulated fraud detection process, which typically involves intensive processing of each transaction using ML models.

1. First, create a custom receiver that will handle fraud detection computations on the results:

2. Next, stream a list of sample transactions across the cluster using a dummy table that partitions data by transaction ID and FraudDetectorReceiver for fraud detection. Subscribe to the results to log each processed transaction, handle errors, and confirm when streaming completes:

Custom Marshallers in .NET

In .NET, you can define custom marshallers by implementing the IMarshaller interface.

For example, the code below demonstrates how to use JsonMarshaller to serialize data, arguments, and results.

Tracking Failed Entries

If the data streamer fails to process any entries, it collects the failed items in a DataStreamerException. You can access the failed entries using the failedItems() method.

The streamer applies entries in the background, so it does not report a failure from the call that submits an entry. It completes the streaming operation with the exception instead, so attach your failure handling to that operation. In Java, this means attaching a handler to the future returned by streamData(). Once the streamer fails, it stops accepting entries, and any remaining submit() calls throw an IllegalStateException:

The streamer completes its future with a DataStreamerException directly, but a handler attached further down the chain receives it wrapped in a CompletionException. The helper below checks both:

Tuning Memory Usage

Data streamer may require significant amount of memory to handle the requests in orderly manner. Depending on your environment, you may want to increase or reduce the amount of memory reserved by the data streamer.

For every node in the cluster, the streamer reserves an amount of memory equal to pageSize (1000 entries by default) multiplied by perPartitionParallelOperations (1 by default) setting. For example, a 10-partition table with default parameters and average entry size of 1KB will reserve 10MB for operations.

You can change these options while creating a DataStreamerOptions object:

Additionally, the data streamer periodically flushes incomplete buffers to ensure that messages are not delayed indefinitely. This is especially useful when a buffer fills slowly or never completely fills due to uneven data distribution.

This behavior is controlled by the autoFlushInterval property, which is set to 5000 ms by default. You can also configure the retryLimit parameter to define the maximum number of retry attempts for failed submissions, with a default value of 16.

See Also

This page is: Copyright © 2026 MariaDB. All rights reserved.

spinner

Last updated

Was this helpful?