NATS - JetStream icon

NATS - JetStream

NATS - JetStream

Publish

AI-generated

Overview

This node integrates with the NATS JetStream messaging system, specifically enabling publishing messages to a JetStream stream. It is useful in scenarios where you want to send data or events asynchronously to other services or components that subscribe to the JetStream subject.

Typical use cases include:

  • Sending notifications or event messages from workflows.
  • Publishing data updates to distributed systems.
  • Integrating n8n workflows with microservices architectures using JetStream as a message broker.

For example, you can publish a JSON payload or binary data to a specific subject in JetStream, optionally adding custom headers to control message metadata.

Properties

Name Meaning
Subject The JetStream subject (topic) to which the message will be published.
Payload Content Type The type of the payload content. Options: "String" for text payloads, "N8n Binary Data" for binary payloads.
Payload The string content to publish when the content type is "String".
Payload Binary Property Name The name of the binary property in the input data to publish when the content type is "N8n Binary Data".
Headers Optional HTTP-style headers to add to the message. Each header consists of a key and value pair.

Output

The node outputs an array of JSON objects representing the result of the publish operation for each input item. Each output item corresponds to one input item processed.

The json output field contains information about the success or failure of the publish action per item. If an error occurs and "Continue On Fail" is enabled, the error message is included in the output JSON for that item.

The node does not output binary data.

Dependencies

  • Requires a connection to a NATS JetStream server.
  • Needs an API authentication token or API key credential configured in n8n to authenticate with the NATS server.
  • The node uses internal helper functions to establish and manage the JetStream connection.

Troubleshooting

  • Connection errors: Ensure the NATS JetStream server URL and credentials are correctly configured.
  • Publish failures: Check that the subject name is valid and that the server allows publishing to it.
  • Binary payload issues: Verify that the specified binary property exists in the input data and contains valid binary data.
  • Headers format: Make sure headers are provided as key-value pairs; invalid headers may cause message rejection.
  • Common error messages:
    • "Error: Unable to connect to NATS server" — check network connectivity and credentials.
    • "Error: Subject is required" — ensure the Subject property is set.
    • "Error: Invalid payload binary property" — verify the binary property name matches input data.

Links and References

Discussion