Publish
AI-generatedOverview
This node publishes messages to a NATS server. It is useful for sending notifications, events, or data streams to other services or applications subscribed to the NATS messaging system. For example, it can be used to send real-time updates or alerts in a distributed system.
Use Case Examples
- Publishing a JSON message to a NATS subject to notify other microservices about a status change.
- Sending binary data as a payload to a NATS subject for processing by a downstream service.
Properties
| Name | Meaning |
|---|---|
| Subject | The subject (topic) to which the message will be published. This is required. |
| Payload Content Type | Specifies the content type of the payload, either a string or n8n binary data. |
| Payload | The message content to publish when the content type is string. |
| Payload Binary Property Name | The property name of the binary data to publish when the content type is binary data. |
| Headers | Optional headers to include with the message, specified as key-value pairs. |
| Options | Additional options to control message publishing behavior, such as saving content as binary, parsing JSON body, limiting max replies, returning only content, requesting multiple replies, and setting a timeout. |
Output
JSON
subject- The subject to which the message was published.content- The content of the published message, either as string or parsed object depending on options.headers- Headers sent with the message.replies- Replies received from the NATS service if any, limited by max replies option.
Dependencies
- Requires a connection to a NATS server via an API key credential.
Troubleshooting
- Common issues include connection failures to the NATS server, which can be resolved by verifying credentials and network access.
- Errors in publishing due to invalid subject or payload format; ensure the subject is a valid string and payload matches the selected content type.
- Timeout errors when waiting for replies can be addressed by adjusting the timeout option or checking the responsiveness of the NATS service.