Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a way to view NATS messages?

Tags:

nats.io

I am trying to look at the messages in a NATS cluster on a certain topic. My google searches led to https://github.com/KualiCo/nats-streaming-console and https://hub.docker.com/r/fjudith/nats-streaming-console but neither npm install nor yarn install worked. I am not sure if thats an issue with the image or if thats my system setting.

And since I am new here, I wasn't allowed to comment. I have been running in circles for sometime with this so any pointers would be highly appreciated.

-Suresh

like image 939
suramana Avatar asked Nov 15 '25 12:11

suramana


1 Answers

Maybe this is not what you are looking for on a cluster (but could be).

Nevermind, in case of a single NATS instance, using the CLI-tools:

Start with a PING

nats --server Host:Port rtt

General access:

nats --user username --password mypassword --server Host:Port

Listing the streams:

nats --user username --password mypassword --server Host:Port stream ls

Subscribing (a shell) onto a streams:

nats --user username --password mypassword --server Host:Port subscribe SUBJECT.STREAM

Publish a "JSON message" onto a stream:

cat <PathToMessage.json> | nats --user username --password mypassword --server Host:Port publish SUBJECT.STREAM --force-stdin

Show all messages published onto a Stream:

nats --user username --password mypassword --server Host:Port stream view

Additionally: Sample JSON Message:

{
  "id": "4152c2e7-f2be-42d8-86fe-5b94f2ed3678",
  "form": "triangle",
  "wrappedData": {
    "Color": "green",
  }
}
like image 129
d.braun1991 Avatar answered Nov 18 '25 19:11

d.braun1991



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!