pucli-0.6.0 is not a library.
pucli
pucli is a small command-line utility for Apache Pulsar focused on two workflows:
- publish one or more messages to a topic
- subscribe to a topic and pipe each message payload to a shell command
It is useful for local testing, smoke checks, and simple event-driven scripts.
Install
Quick examples
Publish a single JSON payload:
Subscribe and process payloads with jq:
Connection options (global)
These options can be used with both pub and sub:
-a, --address <ADDRESS>: Pulsar broker URL (default:pulsar://127.0.0.1:6650)-t, --token <TOKEN>: authentication token
Example:
Publish command
pucli pub publishes one or multiple messages to a topic.
Key options:
-t, --topic <TOPIC>: destination topic (required)-m, --message <MESSAGE>: single message payload-b, --bundle-file <FILE>: file with one message per line-r, --repeat <N>: repeat the message setNtimes-c, --connections <N>: number of producers used in parallel-n, --name <NAME>: producer name prefix--meta <KEY=VALUE>: producer metadata (repeatable)
Notes:
- If
--bundle-fileis set, its lines are used as messages. - If
--bundle-fileis not set,--messageis used. - If neither is set, no messages are sent.
Examples:
# publish messages from a file
# publish one message 100 times over 4 parallel producers
# add producer metadata
Subscribe command
pucli sub consumes messages and forwards each payload to a command via stdin.
Key options:
-t, --topic <TOPIC>: source topic (required)-s, --subscription <SUBSCRIPTION>: subscription name (required)-m, --mode <MODE>:exclusive|shared|failover|key-shared(default:exclusive)-o, --once: spawn the callback command only once and keep piping messages to it-n, --new-line: append newline (\n) to each payload before writing to callback stdin--ephemeral: create a non-durable subscription (useful for troubleshooting sessions)--unsubscribe-on-exit: explicitly unsubscribe on graceful shutdown (Ctrl-C)--meta <KEY=VALUE>: consumer metadata (repeatable)<command>...: callback command and args (required, after--)
Examples:
# pretty-print JSON payloads
# keep a single process alive and feed all messages to it
# shared subscription mode
Behavior notes
- On
Ctrl-C, the subscriber stops gracefully. - With
--ephemeral, the subscription is non-durable and is not kept after consumer disconnect. - With
--unsubscribe-on-exit,pucliunsubscribes on graceful shutdown. - Message ack/nack is based on callback execution success:
- ack when command execution succeeds
- nack when command execution fails