Skip to content

CLI: Produce & Consume

Danube includes data-plane messaging commands directly inside the unified danube binary under danube ctl. You can publish test payloads, benchmark throughput, filter Key-Shared streams, validate schemas, and inspect messages in human-readable text or structured JSONL without installing a separate messaging CLI tool.


Global Data-Plane Connection & Security Options

Section titled “Global Data-Plane Connection & Security Options”

Both danube ctl produce and danube ctl consume connect to the broker data-plane gRPC endpoint (default http://127.0.0.1:6650) and share the same TLS and JWT authentication options (DataAuthArgs):

FlagEnvironment VariableDefaultDescription
-s, --service-addr <URL>DANUBE_SERVICE_ADDRhttp://127.0.0.1:6650Broker service gRPC URL
--tlsDANUBE_TLSfalseEnable TLS transport
--ca <PATH>DANUBE_CA—Path to CA certificate PEM (required when --tls is enabled)
--cert <PATH>DANUBE_CERT—Path to client certificate PEM (for mTLS)
--tls-key <PATH>DANUBE_KEY—Path to client private key PEM (for mTLS)
--token <JWT>DANUBE_TOKEN—JWT Bearer token for authentication

You can export these variables once per shell session when working against a secured cluster:

Terminal window
export DANUBE_SERVICE_ADDR=https://broker1.example.com:6650
export DANUBE_TLS=true
export DANUBE_CA=./tls/ca.pem
export DANUBE_TOKEN="$(cat bootstrap_admin.token)"

Publish one or more messages to a Danube topic, optionally with routing keys, custom attributes, reliable dispatch, partitions, and Schema Registry integration.

FlagShortDefaultDescription
--service-addr <URL>-shttp://127.0.0.1:6650Broker service address (DANUBE_SERVICE_ADDR)
--producer-name <NAME>-ndanube_producerProducer identifier
--topic <TOPIC>-t/default/test_topicTarget topic (/<namespace>/<topic>)
--message <TEXT>-m—Message payload string
--file <PATH>-f—Read message payload from a local file
--count <N>-c1Number of messages to publish
--interval <MS>-i500Delay between messages in milliseconds (minimum: 10 ms)
--partitions <N>-p—Partition count when creating/using a partitioned topic
--attributes <K=V>-a—Message attributes (key-value pairs)
--key <KEY>-k—Routing key (used for key-shared delivery / key routing)
--reliable-rfalseEnable reliable dispatch strategy
--schema-subject <SUBJ>——Existing Schema Registry subject to attach to the producer
--schema-version <N>——Pin a specific schema version number
--schema-min-version <N>——Require at least this minimum schema version
--schema-file <PATH>——Auto-register a schema file (subject defaults to the topic path with / trimmed and replaced by -, e.g., /default/events → default-events)
--schema-type <TYPE>——Schema type: bytes, string, number (alias int64), json-schema, avro, or protobuf
Terminal window
# Send a single message
danube ctl produce --topic /default/events --message "hello danube"
# Stream 100 messages every 50 ms on a 4-partition topic using reliable dispatch
danube ctl produce \
--topic /default/orders \
--partitions 4 \
--reliable \
--count 100 \
--interval 50 \
--message '{"order_id":"ord-100","total":42.50}'

Subscribe to a topic and stream incoming messages to stdout.

When a received message carries a schema_id, danube ctl consume automatically queries the Schema Registry, caches the schema definition, validates json_schema payloads when applicable, and pretty-prints json_schema and avro payloads.

FlagShortDefaultDescription
--service-addr <URL>-shttp://127.0.0.1:6650Broker service address (DANUBE_SERVICE_ADDR)
--topic <TOPIC>-t/default/test_topicTopic to subscribe to (/<namespace>/<topic>)
--consumer-name <NAME>-ndanube_consumerConsumer identifier
--subscription <NAME>—danube_subSubscription name (note: no short flag)
--subscription-type <TYPE>—sharedSubscription mode: exclusive, shared, fail-over, or key-shared
--key-filter <GLOB>——Repeatable routing-key glob pattern (applies to key-shared subscriptions only)
--limit <N>-l0Stop after receiving N messages (0 consumes continuously)
--output <FORMAT>-otextOutput format: text or jsonl
Terminal window
# Consume continuously on a shared subscription
danube ctl consume --topic /default/events --subscription cli-workers
# Consume the next 10 messages on an exclusive subscription as JSON Lines
danube ctl consume \
--topic /default/orders \
--subscription audit-reader \
--subscription-type exclusive \
--limit 10 \
--output jsonl

Every Danube container already includes danube, so you can run danube ctl produce and danube ctl consume directly with docker exec:

Terminal window
# Terminal 1: consume messages
docker exec -it danube-broker1 danube ctl consume \
--service-addr http://127.0.0.1:6650 \
--topic /default/test \
--subscription demo-sub
# Terminal 2: publish 20 messages
docker exec danube-broker1 danube ctl produce \
--service-addr http://127.0.0.1:6650 \
--topic /default/test \
--count 20 \
--message "Hello from danube ctl"