This page has moved to https://docs.nats.io.
Click here if you are not redirected.
NATS supports request/reply messaging. In this tutorial you explore how to exchange point-to-point messages using NATS.
Go and the NATS server should be installed.
You will use these sessions to run the NATS request and reply clients.
% cd $GOPATH/src/github.com/nats-io/nats.go/examples
% go run nats-rply/main.go foo "this is my response"
You should see the message
Receiver is listening, and that the NATS receiver client is listening on the "help.please" subject. The reply client acts as a receiver, listening for message requests. In NATS, the receiver is a subscriber.
% go run nats-req/main.go foo "request payload"
The NATS requestor client makes a request by sending the message "some message" on the “help.please” subject.
The NATS receiver client receives the message, formulates the reply ("OK, I CAN HELP!!!"), and sends it to the inbox of the requester.