NATS JetStream icon

NATS JetStream

Manage NATS JetStream streams, consumers, and publish messages

Actions11

Overview

This node manages NATS JetStream streams, consumers, and messages. Specifically for the Stream - Purge operation, it allows users to purge all messages from a specified JetStream stream. This is useful when you want to clear out all stored messages in a stream without deleting the stream itself, for example, to reset the stream state or free up storage space.

Practical examples:

  • Clearing event logs stored in a JetStream stream before starting a new batch of events.
  • Removing outdated or corrupted messages from a stream while keeping the stream configuration intact.

Properties

Name Meaning
Stream Name Name of the JetStream stream to purge. Stream names should be descriptive (e.g., "EVENTS").

Output

The node outputs a JSON object representing the result of the purge operation. The exact structure depends on the underlying JetStream API response but typically includes confirmation that the stream was purged successfully or details about the purge action.

No binary data output is produced by this operation.

Example output JSON might look like:

{
  "success": true,
  "streamName": "EVENTS",
  "purgedMessagesCount": 1234
}

(Note: The actual fields depend on the JetStream manager's purge method response.)

Dependencies

  • Requires an active connection to a NATS server with JetStream enabled.
  • Needs an API key credential or equivalent authentication token configured in n8n to connect securely to the NATS server.
  • Uses bundled NATS client libraries to interact with JetStream.
  • No additional external services are required beyond the NATS JetStream server.

Troubleshooting

  • Common issues:

    • Incorrect or missing stream name: The node requires a valid stream name; ensure the stream exists on the JetStream server.
    • Connection failures: Verify network connectivity and correct API credentials.
    • Permission errors: The API key used must have permissions to manage streams and perform purge operations.
  • Error messages:

    • Unknown stream operation: purge — indicates the operation name is not recognized; ensure "purge" is spelled correctly and supported.
    • NATS JetStream operation failed: <error message> — generic failure; check the detailed error message for specifics such as authentication failure, stream not found, or permission denied.
  • Resolution tips:

    • Double-check the stream name spelling and existence.
    • Confirm credentials and network access to the NATS server.
    • Review JetStream server logs for more detailed error information if available.

Links and References

Discussion