NSQ Client
x/nsqClient
component: v0.33.0+ NSQ producer component. Used to publish messages to specified NSQ topics.
# Configuration
This component supports reusing shared NSQ connection clients through the server
field to avoid creating duplicate connections. See Component Connection Reuse.
Field | Type | Required | Description | Default Value |
---|---|---|---|---|
server | string | Yes | NSQ server address, supports multiple formats: 1. Single nsqd: "127.0.0.1:4150" 2. Multiple nsqd: "127.0.0.1:4150,127.0.0.1:4151" 3. Lookupd address: "http://127.0.0.1:4161,http://127.0.0.1:4162" | 127.0.0.1:4150 |
topic | string | Yes | Publish topic, supports using Component Configuration Variables for dynamic configuration | device_msg |
authToken | string | No | NSQ authentication token | None |
certFile | string | No | TLS certificate file path | None |
certKeyFile | string | No | TLS private key file path | None |
# Working Principle
- The component initializes by connecting to the NSQ server based on configuration
- Supports connecting to single or multiple nsqd instances, also supports discovering nsqd through lookupd
- Upon receiving a message, publishes the message content to the specified topic
- Routes through Success chain upon successful publishing, routes through Failure chain on failure
- The component automatically manages connection lifecycle, including reconnection
# Relation Type
- Success: Message is sent to
Success
chain in the following cases:- Message successfully published to NSQ server
- Received confirmation from NSQ server
- Failure: Message is sent to
Failure
chain in the following cases:- Failed to connect to NSQ server
- Failed to publish message
- Configuration parameter error
- TLS certificate loading failure
# Execution Result
After component execution:
- msg.data remains unchanged
- metadata remains unchanged
- msgType remains unchanged
# Configuration Example
{
"id": "s5",
"type": "x/nsqClient",
"name": "Publish to NSQ",
"debugMode": true,
"configuration": {
"server": "127.0.0.1:4150",
"topic": "device.msg.${deviceType}",
"authToken": "your-auth-token"
}
}
1
2
3
4
5
6
7
8
9
10
11
2
3
4
5
6
7
8
9
10
11
# Application Example
Application example reference: nsq_client_test (opens new window)
Edit this page on GitHub (opens new window)
Last Updated: 2025/07/22, 15:00:05