Streaming Processing Mode
In Streaming Processing Mode, Nussknacker continuously processes incoming events as they arrive, enabling real-time decisions and actions.
Unlike batch processing, where data is collected and processed in chunks, streaming treats data as a flow of events — such as user interactions, sensor readings, or updates in a database — and reacts to them with minimal delay. This makes it ideal for time-sensitive use cases like fraud detection, personalization, monitoring, or operational automation.
Nussknacker Cloud supports a variety of streaming data sources, allowing you to build scenarios that ingest and act on events in motion. Whether your data comes from messaging systems, change data capture (CDC) tools, or other event streams, Nussknacker helps you transform and respond to those events as they happen — all without writing complex code.
Notion of time
Notion of passing time is very important in dealing with real time events processing. Functionality like aggregates in time windows and stream joins needs information about event creation timestamp. This information can be made available to Nussknacker using different methods:
- events in Kafka topics have event creation time, unless overridden (see next), this information will be used by Nussknacker
- for Kafka sources you can configure a SpEL expression allowing Nussknacker to compute the event creation time.
- for Table sources, you can define event time attributes while configuring the Table integration
Please see following excellent references to learn about basic concepts:
Sources and Sinks
In the streaming processing mode Nussknacker supports a wide range of sources (both bounded and unbounded) and sinks.
Unbounded sources: Event Generator
Unbounded sources and sinks:
Bounded sources and sinks:
Contact us if your source or sink is not supported yet.
You can have multiple sources and sinks in a scenario working in the streaming processing mode.
Bounded sources and streaming mode
Flink, and consequently Nussknacker can process bounded sources in the streaming mode. When all records from the bounded source are ingested and processed, the scenario simply terminates. You can configure Nussknacker to derive event time from the data carried by records ingested from bounded sources. This allows you to use event-time-based components such as aggregates in time windows, debounce or deduplicate.
Predefined variables
In Streaming processing mode the #input variable is associated with an event that has been read from a source and contains the data read from the source.
Some nodes specific to the streaming processing nodes (e.g. aggregates) may terminate the incoming events and create new events. In such cases, the #input variable will no longer be available downstream - only the newly created record (and the variables associated with it) will exist downstream.
The #meta variable carries meta information about the scenario under execution. This variables' contents can change during scenario execution as it's a dynamically allocated variable. The following meta information elements are available:
- processName - name of the Nussknacker scenario
- scenarioVersion - version of the scenario that is running (in a scenario test: the version being edited)
- scenarioLabels - labels of the scenario
- properties - scenario properties
- host - name of the machine that runs the scenario: the value of the
NU_HOST_NAMEenvironment variable, otherwiseHOSTNAME, otherwise the name the JVM resolves. See below for containers - nussknackerVersion - version of Nussknacker that runs the scenario
- run - the scheduled run the scenario was started for,
nullwhen it was not started by the scheduler (a manual deploy, a scenario test):id- the id of the scheduled run,logicalTime- the tick the run is for, aLocalDateTimein the scheduler's time zone (it stays the same when the run starts late or is retried, and has the same value in both passes of an hour repeated when the clocks go back),scheduleName- the name of the schedule, empty for a single unnamed cron. Check it before use:#meta.run != null ? #meta.run.logicalTime.toLocalDate : #DATE.nowAtDefaultTimeZone.toLocalDate
In Docker and Kubernetes the JVM sees only the container or pod, so pass the name you want in NU_HOST_NAME to the
process that runs the scenario (the Flink TaskManager, the Lite runtime, or the Designer when it runs Flink as a
MiniCluster):
- Docker Compose:
NU_HOST_NAME: ${NU_HOST_NAME}in the service'senvironment, with the host's name in.env(NU_HOST_NAME=worker-3) or exported in the shell that runsdocker compose(export NU_HOST_NAME=$(hostname)); - Kubernetes: the node name from the downward API,
valueFrom: {fieldRef: {fieldPath: spec.nodeName}}, ormetadata.namefor the pod name.
In a scenario test #meta.host is the Designer's host, since the test runs there.
For a Kafka topic source, the record metadata is available in #inputMeta with these fields:
- headers
- key
- leaderEpoch
- offset
- partition
- timestamp
- timestampType
- topic
Consult Kafka documentation for the exact meaning of those fields.
HTTP Endpoint, WebSocket Client and WebSocket Server sources expose only #inputMeta.httpHeaders, a map of forwarded
HTTP headers.
Exactly-once processing
Nussknacker allows to process events using the exactly-once semantics; this feature is provided by Flink.
If you use Kafka compatible sinks contact us if you need this feature enabled. If you use database sink, you need to ensure that Flink decides to use upsert rather then insert method for the events written to the sink. This is achieved by defining a primary key on the sink table. You can read more about this in the Flink documentation.
Scenario properties
Click Kebab menu icon (three vertically aligned dots next to the scenario name) on the right panel and access the properties of the scenario.
Scenario properties explained
| Property name | Description |
|---|---|
| Name | Scenario name |
| Checkpoint interval in seconds | Checkpointing is a key Apache Flink mechanism used to ensure that in the case of failure Flink jobs (= deployed Nussknacker scenarios) can be resumed from the last saved checkpoint See here for explanation. |
| Parallelism | Parallelism determines how many workers (called task managers in Flink) are employed to process events. |
| Spill state to disk | Stateful transformers need to remember data "between" events; this data is called state. The state can grow very large, if there is not enough RAM to keep state in memory, it can be spilled to disk. |
| IO mode | You can speed up processing in enrichers case by choosing asynchronous. If you choose so, it may happen that events will be leaving your scenario in different order than they arrived - so watch out if your downstream logic makes assumptions on the sequencing of events |