Skip to content

ZeroMQ (0mq) is a light-weight messaging framework with various socket types. Tenzir supports writing to PUB sockets and reading from SUB sockets, both in bind mode and connect mode.

ZeroMQPUBconnectZeroMQPUBzmq://1.2.3.4zmq://1.2.3.4ZeroMQSUBZeroMQSUBzmq://5.6.7.8zmq://5.6.7.8Subscribe (connect)Subscribe (listen)Publish (listen)Publish (connect)

Use the IP address 0.0.0.0 to listen on all available network interfaces.

The new executor provides event-oriented ZeroMQ operators:

  • from_zmq: Connects as a SUB socket and receives events.
  • accept_zmq: Binds a SUB socket and receives events.
  • to_zmq: Connects as a PUB socket and sends events.
  • serve_zmq: Binds a PUB socket and sends events.

Tenzir documents these operators for PUB/SUB-style use. ZeroMQ itself does not have a first-class topic abstraction. Instead, Tenzir uses an optional prefix that is prepended to outgoing messages and matched by subscribers with ZeroMQ’s native byte-prefix filtering. Receivers strip the matched prefix before running their nested read_* pipeline unless keep_prefix=true.

Because ZeroMQ is entirely asynchronous, publishers send messages even when no subscriber is present. This can lead to lost messages when the publisher begins operating before the subscriber. To avoid data loss due to such races, pass monitor=true on to_zmq, serve_zmq, or the legacy save_zmq operator to wait until at least one remote peer has connected on TCP transports.

Connect to a remote publisher and parse JSON

Section titled “Connect to a remote publisher and parse JSON”
from_zmq "tcp://collector.example.com:5555" {
read_json
}
accept_zmq "tcp://0.0.0.0:5555", prefix="alerts/" {
read_ndjson
}
export
serve_zmq "tcp://0.0.0.0:5555", encoding="json", prefix=kind + "/"
export
to_zmq "tcp://collector.example.com:5555", encoding="json"

Last updated: