ZeroMQ Trigger
AI-generatedOverview
This node acts as a trigger that starts an n8n workflow when a message is received on a ZeroMQ socket. It supports three types of ZeroMQ sockets: Reply (REP), Subscribe (SUB), and Pull. The node can either bind to a socket address (acting as a server) or connect to an existing server socket.
Common scenarios include:
- Listening for messages published on a specific topic in a pub-sub pattern (SUB).
- Receiving requests and sending automatic replies in a request-reply pattern (REP).
- Pulling messages from a pipeline of tasks or workers (PULL).
Practical examples:
- Subscribing to sensor data updates published on a certain topic.
- Acting as a service that receives commands and sends acknowledgments automatically.
- Pulling jobs from a distributed queue for processing.
Properties
| Name | Meaning |
|---|---|
| Socket Type | Type of ZeroMQ socket to use. Options: Reply (REP), Subscribe (SUB), Pull |
| Action | Whether to bind (act as server and listen) or connect (connect to a server) |
| Socket Address | The ZeroMQ socket address, e.g., tcp://127.0.0.1:5555 |
| Topic | (Only for SUB) The topic to subscribe to. Leave empty to receive all topics |
| Response (for REP) | (Only for REP) Automatic response message sent upon receiving a message |
Output
The node outputs JSON objects with the following structure:
For SUB sockets:
{ "topic": "<topic string>", "message": "<message string>" }Where
topicis the subscribed topic andmessageis the content of the message received.For REP sockets:
{ "message": "<message string>" }The message received from the requester. The node also sends back an automatic response configured by the user.
For PULL sockets:
{ "message": "<message string>" }The pulled message from the connected socket.
No binary data output is produced by this node.
Dependencies
- Requires the
zeromqNode.js package to interact with ZeroMQ sockets. - Needs a running ZeroMQ server or publisher to connect or bind to.
- No special environment variables are required beyond standard network connectivity.
Troubleshooting
- Invalid socket type error: Occurs if an unsupported socket type is selected. Ensure the socket type is one of REP, SUB, or PULL.
- Connection errors: If binding or connecting to the specified socket address fails, verify the address format and that the target server is reachable.
- No messages received: For SUB sockets, ensure the topic matches what publishers send; leaving it empty subscribes to all topics.
- Unexpected behavior with REP sockets: The node automatically sends a fixed response after receiving a message. Customize the response property as needed.
- Resource cleanup: The node closes the socket properly on workflow stop, but if errors occur, check network stability and socket lifecycle.
