Actions2
Overview
This node integrates with the NATS JetStream messaging system to publish messages to a stream. The "Publish" operation allows users to send data payloads with optional custom headers to a specified subject within JetStream. This is useful in scenarios where you want to push events, notifications, or any message data into a distributed messaging system for asynchronous processing, event-driven architectures, or microservices communication.
Practical examples include:
- Sending real-time updates from an application to other services.
- Publishing sensor data streams for IoT applications.
- Broadcasting notifications or commands to multiple subscribers.
Properties
Name | Meaning |
---|---|
Subject | The target subject (topic) in JetStream where the message will be published. |
Payload Content Type | The type of content being sent as payload. Options: "String" (plain text) or "N8n Binary Data". |
Payload | The actual message content as a string (used if content type is "String"). |
Payload Binary Property Name | The name of the binary property containing the payload data (used if content type is "N8n Binary Data"). |
Headers | Optional HTTP-style headers to include with the message. Multiple key-value pairs can be added. |
Output
The node outputs JSON data representing the result of the publish operation. Typically, this includes metadata about the published message such as confirmation or status details returned by the JetStream service.
If the payload was binary, the node handles the binary data accordingly but does not output binary data itself; it only sends it to JetStream.
Dependencies
- Requires connection to a NATS JetStream server.
- Needs an API authentication token or API key credential configured in n8n to authenticate with the NATS service.
- Uses an internal JetStream service client to perform operations.
Troubleshooting
- Common issues:
- Incorrect or missing subject name will cause publishing to fail.
- Invalid or missing credentials will prevent connection to the JetStream server.
- Mismatch between payload content type and provided payload (e.g., selecting binary but not providing a valid binary property) may cause errors.
- Error messages:
- Errors related to authentication failure indicate problems with the API key or token configuration.
- Errors about missing parameters usually mean required fields like "Subject" or "Payload" are empty.
- Network or connection errors suggest issues reaching the JetStream server endpoint.
To resolve these, verify all required properties are correctly set, ensure credentials are valid and have proper permissions, and confirm network connectivity to the JetStream server.