Actions11
Overview
This node manages NATS JetStream streams, consumers, and message publishing within the NATS messaging system. Specifically, for the Stream - Create operation, it allows users to create a new JetStream stream with detailed configuration options such as subjects to consume, storage type, retention policy, message limits, and replication settings.
Typical use cases include:
- Setting up event streaming pipelines where messages are published to specific subjects and consumed reliably.
- Creating durable streams for event sourcing or audit logging with configurable retention and storage.
- Managing message lifecycle policies to optimize resource usage and ensure data availability.
For example, you might create a stream named "EVENTS" that listens to subjects like events.orders and events.inventory, stores messages on disk, retains them based on limits, and replicates data across multiple nodes for high availability.
Properties
| Name | Meaning |
|---|---|
| Stream Name | The name of the JetStream stream to create. Should be descriptive to identify the stream's purpose (e.g., "EVENTS"). |
| Stream Configuration | A collection of optional settings defining the stream's behavior: • Subjects: List of subjects this stream will consume; supports wildcards like events.* or events.>.• Description: Human-readable description. • Storage Type: Storage backend, either "File" (persistent) or "Memory" (non-persistent). • Retention Policy: How messages are retained — "Limits", "Interest", or "Work Queue". • Max Messages: Max number of messages stored (-1 for unlimited). • Max Messages Per Subject: Max messages per subject (-1 for unlimited). • Max Age (Seconds): Max age of messages in seconds (0 for unlimited). • Max Bytes: Max total size in bytes (-1 for unlimited). • Max Message Size: Max individual message size in bytes (-1 for unlimited). • Discard Policy: Policy when limits reached — discard old messages ("Old") or reject new ones ("New"). • Number of Replicas: Number of replicas (1-5) for availability. • Max Consumers: Max number of consumers (-1 for unlimited). • Duplicate Window (Nanoseconds): Time window for duplicate detection (0 disables). • No Acknowledgments: Whether to disable acknowledgments for the stream (boolean). |
Output
The node outputs an array with one item per input, each containing a json field representing the result of the stream creation operation. This JSON typically includes details about the created stream, such as its name, configuration, and status returned by the JetStream management API.
No binary data output is produced by this operation.
Example output snippet (conceptual):
{
"json": {
"name": "EVENTS",
"config": {
"subjects": ["events.orders", "events.inventory"],
"storage": "file",
"retention": "limits",
"max_msgs": 100000,
...
},
"created": true
}
}
Dependencies
- Requires a valid connection to a NATS server with JetStream enabled.
- Needs an API key credential or equivalent authentication configured in n8n to connect securely to the NATS server.
- Uses bundled NATS client libraries internally to manage connections and perform operations.
- No additional external services beyond the NATS JetStream server are required.
Troubleshooting
Common Issues:
- Connection failures due to incorrect or missing credentials.
- Invalid stream names or subject patterns causing errors.
- Misconfiguration of stream parameters leading to rejection by the JetStream server.
- Attempting to create a stream that already exists without proper update logic.
Error Messages:
"Unknown stream operation: create": Indicates the operation name is not recognized; verify spelling and supported operations."NATS JetStream operation failed: ...": General failure connecting or executing the operation; check network connectivity and credentials.- Validation errors related to subject syntax or parameter ranges; ensure subjects follow NATS wildcard rules and numeric values are within allowed limits.
Resolution Tips:
- Double-check all input parameters for correctness.
- Ensure the NATS server is reachable and JetStream is enabled.
- Use descriptive stream names and valid subject patterns.
- Review JetStream server logs for more detailed error information if available.