Credits:The XMQ web site is provided by Linotex.The XMQ and SPTK Windows installers are created with Advanced Installer free Open-Source license.
There were 0 unique visitors to this page

xmq_pub

The xmq_pub utility is a command-line client for MQTT version 5/3.1.1/3.1 used for publishing messages.

Usage

xmq_pub [options]

Examples

# Publish one message to a topic:
xmq_pub -h broker.example.com -t sensors/temperature -m "22.5"

# Publish 1000 messages at 100 per second with QoS 1:
xmq_pub -h broker.example.com -t sensors/%ClientIndex% -r 1000 -g 100 -q 1

# Publish a retained message:
xmq_pub -h broker.example.com -t status -m "online" -R

# Read messages from stdin, one per line:
cat messages.txt | xmq_pub -h broker.example.com -t logs -s

Options

  • -m, --message: Message text.
  • -q, --qos: Message QOS: 2. (Default: 0)
  • -r, --repeat: Message repeat count. (Default: 1)
  • -x, --session-expiry-interval: Session expiry interval, the default is no expire.
  • -f, --message-file: Send file content as message.
  • -M, --max-inflight: The maximum inflight messages for QoS 1/2. (Default: 128)
  • -g, --message-rate: Messages send rate, messages per second. (Default: 0)
  • -t, --topic: Message topic. Multiple topics can be separated by semicolon. The topic may include %ClientIndex% that is substituted by the client index (number).
  • -R, --retain: Publish as a retained message: the broker keeps the last one per topic and gives it to each new subscriber.
  • -s, --stdin: Read messages from stdin, one message for per line.
  • --quiet: Don't print to stdout.
  • -d, --debug: Print debug messages.
  • --help: Print this help.
  • -c, --disable-clean-session: Disable clean session.
  • -l, --send-timestamp: Inject a send timestamp at the beginning of each message. Used by xmq_sub for latency measurements.