Skip to main content

Command line

The mojay command creates topics, sends and reads messages, and shows what is actually stored in a data folder. It is the tool for exploring and debugging: your application itself uses the Rust or Node.js library.

mojay create-topic orders --partitions 3
echo '{"order": 1}' | mojay produce orders --key client-42
mojay tail orders --follow

Install​

The command line is the mojay-cli crate, which builds a binary called mojay:

cargo install mojay-cli

The mojay binary is then in ~/.cargo/bin. From a clone of the repository, cargo install --path cli installs the current version, and cargo run -p mojay-cli -- <command> runs it without installing.

The command line is a separate package so that its dependencies are not imposed on applications that only use the library.

The data folder​

Every command works on a data folder, chosen in this order:

  1. the --data <folder> option (or -d), placed before or after the command;
  2. the MOJAY_DATA environment variable;
  3. by default, ./data.
export MOJAY_DATA=/var/lib/myapp/events
mojay topics
mojay -d ./other-data describe orders

Only create-topic creates the folder if it does not exist. The other commands refuse a folder that is not a Mojay folder, so a typo never creates an empty one somewhere else:

$ mojay -d elsewhere topics
error: elsewhere is not a Mojay data directory (use --data or MOJAY_DATA)

Commands​

CommandPurposeChanges data?
create-topicCreates a topicYes
topicsLists the topicsNo
describeConfiguration, partitions, segments, group lagNo
produceSends messagesYes
tailShows messagesNo
dumpShows the raw content of a segment fileNo

mojay --help and mojay <command> --help list every option.

create-topic​

mojay create-topic <name> [options]
OptionDefaultEffect
-p, --partitions <n>1Number of partitions, fixed at creation.
--segment-size <size>64MiBSize of a segment file before moving to the next one.
--fsync <policy>alwaysalways, never, or an interval such as 100ms. See Durability.
--retention-size <size>noneMaximum size of one partition. Beyond it, the oldest segments are deleted.
--retention-time <duration>noneMaximum age of a segment, since its last write.
$ mojay create-topic events -p 4 --fsync 100ms --retention-size 10GiB --retention-time 7d
topic "events" created (4 partitions)

Names accept letters, digits, ., _ and -.

topics​

Lists the topics, one per line, sorted by name.

mojay topics

describe​

Shows a topic's configuration, the state of each partition, and the position of each consumer group. It is the command to keep at hand while an application runs.

$ mojay describe orders
topic orders
partitions 3
segments 64 MiB max
fsync always
retention 7d per segment

partition start read limit messages segments size
0 0 2 2 1 127 B
1 0 2 2 1 98 B
2 0 1 1 1 56 B

group partition committed lag
billing 0 2 0
billing 1 1 1
billing 2 1 0
  • start: the first available offset. It moves forward when retention deletes segments.
  • read limit: the first offset not yet readable. You can read start up to, but not including, read limit.
  • lag: the messages the group has not committed yet on that partition.

Here, the billing group processed everything, then a new message arrived on partition 1: the group is one message behind.

produce​

Sends one message with the given value or, without a value, one message per line of standard input. Prints partition:offset for each message.

mojay produce <topic> [value] [options]
OptionEffect
-k, --key <key>Message key. It picks the partition (murmur2, like Kafka).
-p, --partition <n>Forces the partition. With neither key nor partition, messages are spread round-robin.
-H, --header <key=value>A header. Repeatable.
-q, --quietPrints nothing.
$ mojay produce orders '{"order": 1}' -k client-42 -H source=web
0:0
$ printf 'first\nsecond\nthird\n' | mojay produce orders
0:1
1:0
2:0

produce works while applications are writing to the same topic: writers take turns on each partition.

tail​

Shows a topic's messages. tail is a plain reader: it joins no group and commits nothing, so it has no effect on your consumers.

mojay tail <topic> [options]
OptionEffect
-p, --partition <n>A single partition (default: all).
-n, --last <n>Only the last n messages of each partition.
--offset <n>Starts at this offset. Requires --partition.
-f, --followKeeps showing new messages, until Ctrl-C.
--fullShows full values (otherwise cut at 120 characters).

Each line gives partition:offset, the UTC timestamp, the key, the value and the headers:

$ mojay tail orders
0:0 2026-11-20T13:37:52.209Z key="client-42" value="{\"order\": 1}" source="web"
0:1 2026-11-20T13:37:52.238Z key=null value="first"
1:0 2026-11-20T13:37:52.244Z key=null value="second"
2:0 2026-11-20T13:37:52.252Z key=null value="third"

Text is shown in quotes, with special characters escaped. A binary value is shown in hexadecimal (0xff0010), and a missing key or value as null.

dump​

Shows the raw content of segment files, record by record: position in the file, offset, size and content. Use it to check by eye what is stored, or to understand a damaged file. dump never repairs anything.

mojay dump <topic> [-p <partition>] [--index] [--full]
mojay dump <file.log>
$ mojay dump orders -p 0 --index
== data/topics/orders/p0/00000000000000000000.log (127 B, base 0)
valid header, format v1
position offset size timestamp contents
16 0 71 2026-11-20T13:37:52.209Z key="client-42" value="{\"order\": 1}" source="web"
87 1 40 2026-11-20T13:37:52.238Z key=null value="first"
2 readable record(s)
index: 0 entry(ies)

On a damaged file, dump shows everything before the problem, then where and why the rest cannot be read:

$ mojay dump data/topics/orders/p0/00000000000000000000.log
…
1 readable record(s)
!! unreadable tail at position 87: 40 B (invalid CRC)

--index also shows the index entries and flags the inconsistent ones. The file layout is described in Record format.

Units​

TypeExamplesAccepted units
Size4096, 512B, 64KiB, 16MiB, 10GiBB, KiB/K, MiB/M, GiB/G, TiB/T, always base 1024
Duration250ms, 30s, 15m, 12h, 7dms, s, m/min, h, d. The unit is required.

Exit codes​

CodeMeaning
0Success. Output closed along the way (mojay tail orders | head) counts as success.
1Error, explained on standard error (error: …).
2Invalid arguments: the command's usage is printed.