Using the NATS Admin CLI
JAMS installs the NATS administration CLI, nats.exe, alongside the server in the NATS folder, by default C:\Program Files\MVPSI\JAMS\Scheduler\NATS. It is the tool for inspecting streams, consumers, and individual messages, and it replaces the role the Get-JMMsmq cmdlet played under MSMQ.
The bundled version is 0.4.0, matched to the bundled nats-server 2.14.1.
nats.exe can purge streams, delete consumers, and consume messages. Used carelessly against a running JAMS system it destroys scheduling messages. Everything under Inspecting is read-only and safe. Everything under Commands That Change Things is not.
One-Time Setup: Create a TLS Context
NATS requires mutual TLS, so the CLI cannot connect until you tell it which certificate to present. Save that once as a named context, and every later command uses it. Run this from the NATS folder in an elevated prompt so the relative filenames resolve:
cd "C:\Program Files\MVPSI\JAMS\Scheduler\NATS"
nats context add jams --server nats://localhost:4222 `
--tlsca nats-ca.pem --tlscert nats-server-cert.pem --tlskey nats-server-key.pem --select
Confirm it works:
nats context info
nats server check connection
OK Connection OK proves the certificate, the CA, and the connection are all good. If it fails, the problem is TLS or the port. See Troubleshooting NATS.
nats server info and nats server report do not work hereThey query the server through its system account, and the JAMS configuration defines no accounts. They fail with:
nats: error: no results received, ensure the account used has system privileges and appropriate permissions
This is expected. Use nats server check connection or nats rtt for connectivity, the stream and consumer commands below for JetStream state, and the monitoring endpoint for server-level information.
Contexts are stored per Windows user under %USERPROFILE%\.config\nats\context. Each administrator creates their own and needs read access to the three .pem files, which setup restricts.
To inspect the other node of a failover pair, add a second context pointing at it. You present this machine's certificate to the peer's broker:
nats context add jams-peer --server nats://<OtherNodeName>:4222 `
--tlsca nats-ca.pem --tlscert nats-server-cert.pem --tlskey nats-server-key.pem
nats context select jams-peer
nats server check connection
nats stream ls
nats context select jams
This needs TCP 4222 open between the nodes and both certificates chaining to the same root CA, so it doubles as the test that a failover pair is wired correctly. See NATS in a Failover Environment.
Inspecting
All of these are read-only.
# Which streams exist? Expect JAMS_RELIABLE, and JAMS_SCOM if SCOM is in use.
nats stream ls
# Depth, disk usage, configuration, and sequence numbers
nats stream info JAMS_RELIABLE
# A summary table across all streams
nats stream report
# Which message types are in the stream, with counts
nats stream subjects JAMS_RELIABLE
# Just the counts
nats stream state JAMS_RELIABLE
# Watch one message type go by, live
nats sub "jams.reliable.EntryComplete"
nats sub "jams.transient.AgentChanged"
# The Scheduler's consumer: how many are waiting, how many are unacknowledged
nats consumer info JAMS_RELIABLE JAMS_SCHEDULER
nats consumer report JAMS_RELIABLE
# Connectivity
nats server check connection
nats rtt
Reading the Numbers
From nats consumer info JAMS_RELIABLE JAMS_SCHEDULER:
| Field | Meaning |
|---|---|
| Unprocessed Messages | Waiting to be delivered to the Scheduler. Should be at or near zero. |
| Outstanding Acks | Delivered but not yet acknowledged. Normally 0 or 1, because the Scheduler processes one at a time. |
| Redelivered Messages | Delivered more than once. A non-zero value after a restart is normal. JAMS recognizes duplicates. |
From nats stream info JAMS_RELIABLE, Messages is the closest equivalent to MSMQ queue depth. It should be at or near zero.
If Unprocessed Messages is climbing while Outstanding Acks stays at 0, messages are arriving and nothing is collecting them. Look at the Scheduler service. If Outstanding Acks is stuck at 1, the Scheduler took a message and is stuck on it. Look at the Scheduler log for what it is working on.
Replacing Get-JMMsmq
The Get-JMMsmq cmdlet has been removed along with MSMQ.
| What you used it for | NATS equivalent |
|---|---|
| How many messages are queued? | nats stream info JAMS_RELIABLE or nats consumer info JAMS_RELIABLE JAMS_SCHEDULER |
| Does the queue exist? | nats stream ls |
| What kinds of message are in it? | nats stream subjects JAMS_RELIABLE |
| Look at the messages | nats stream get JAMS_RELIABLE <seq>, see below |
| Empty the queue | nats stream purge JAMS_RELIABLE, see below |
| Is the transport up? | nats server check connection, or Invoke-RestMethod http://127.0.0.1:8222/healthz |
Transient messages have no queue to inspect. To watch them live, as a normal subscriber that takes nothing away from the Scheduler:
nats sub "jams.transient.>"
JAMS_RELIABLE and JAMS_SCOM use work-queue retention, which allows one consumer per subject. Creating a second consumer is rejected with multiple non-filtered consumers not allowed on workqueue stream (10099) or filtered consumer not unique on workqueue stream (10100). Use nats stream get to look at message contents instead.