1
0
mirror of https://github.com/taigrr/nats.docs synced 2025-01-18 04:03:23 -08:00

proof reading commits

This commit is contained in:
ainsley
2019-05-30 12:38:58 -05:00
parent d35e3cb277
commit 602700010d
35 changed files with 100 additions and 99 deletions

View File

@@ -15,7 +15,7 @@ digraph nats_pub_sub {
pub1 sub1 non_active
}
nats-server [shape="box", label="NATS", width=8];
gnatsd [shape="box", label="NATS", width=8];
sub2 [shape="box", label="SUB\ncom.msg.one"];
sub3 [shape="box", label="SUB\ncom.msg.two"];
@@ -26,13 +26,13 @@ digraph nats_pub_sub {
sub2 sub3 sub4
}
pub1 -> nats-server [penwidth=2];
nats-server -> sub1 [penwidth=2];
nats-server -> non_active [style=dashed color=red arrowhead="none"];
pub1 -> gnatsd [penwidth=2];
gnatsd -> sub1 [penwidth=2];
gnatsd -> non_active [style=dashed color=red arrowhead="none"];
nats-server -> sub2 [penwidth=2];
nats-server -> sub3 [style=dashed color=red arrowhead="none"];
nats-server -> sub4 [penwidth=2];
gnatsd -> sub2 [penwidth=2];
gnatsd -> sub3 [style=dashed color=red arrowhead="none"];
gnatsd -> sub4 [penwidth=2];
}
</code></div>
@@ -40,7 +40,7 @@ digraph nats_pub_sub {
Go and the NATS server should be installed.
## 1. Start the NATS server
### 1. Start the NATS server
```sh
% nats-server
@@ -56,17 +56,17 @@ When the server starts successfully, you will see the following messages:
The NATS server listens for client connections on TCP Port 4222.
## 2. Start a shell or command prompt session
### 2. Start a shell or command prompt session
You will use this session to run an example NATS client subscriber program.
## 3. CD to the Go client examples directory
### 3. CD to the Go client examples directory
```sh
% cd $GOPATH/src/github.com/nats-io/nats/examples
```
## 4. Run the client subscriber program
### 4. Run the client subscriber program
```sh
% go run nats-sub.go <subject>
@@ -82,7 +82,7 @@ For example:
You should see the message: *Listening on [msg.test]*
## 5. Start another shell or command prompt session
### 5. Start another shell or command prompt session
You will use this session to run a NATS publisher client.
@@ -92,7 +92,7 @@ You will use this session to run a NATS publisher client.
% cd $GOPATH/src/github.com/nats-io/nats/examples
```
## 7. Publish a NATS message
### 7. Publish a NATS message
```sh
% go run nats-pub.go <subject> <message>
@@ -112,7 +112,7 @@ or
% go run nats-pub.go msg.test "NATS MESSAGE"
```
## 8. Verify message publication and receipt
### 8. Verify message publication and receipt
You should see that the publisher sends the message: *Published [msg.test] : 'NATS MESSAGE'*
@@ -120,7 +120,7 @@ And that the subscriber receives the message: *[#1] Received on [msg.test]: 'NAT
Note that if the receiver does not get the message, check that you are using the same subject name for the publisher and the subscriber.
## 9. Publish another message
### 9. Publish another message
```sh
% go run nats-pub.go msg.test "NATS MESSAGE 2"
@@ -128,23 +128,23 @@ Note that if the receiver does not get the message, check that you are using the
You should see that the subscriber receive message 2. Note that the message count is incremented each time your subscribing client receives a message on that subject:
## 10. Start another shell or command prompt session
### 10. Start another shell or command prompt session
You will use this session to run a second NATS subscriber.
## 11. CD to the examples directory
### 11. CD to the examples directory
```sh
% cd $GOPATH/src/github.com/nats-io/nats/examples
```
## 12. Subscribe to the message
### 12. Subscribe to the message
```sh
% go run nats-sub.go msg.test
```
## 13. Publish another message using the publisher client
### 13. Publish another message using the publisher client
```sh
% go run nats-pub.go msg.test "NATS MESSAGE 3"
@@ -152,17 +152,17 @@ You will use this session to run a second NATS subscriber.
Verify that both subscribing clients receive the message.
## 14. Start another shell or command prompt session
### 14. Start another shell or command prompt session
You will use this session to run a third NATS subscriber.
## 15. CD to the examples directory
### 15. CD to the examples directory
```sh
% cd $GOPATH/src/github.com/nats-io/nats/examples
```
## 16. Subscribe to a different message
### 16. Subscribe to a different message
```sh
% go run nats-sub.go msg.test.new
@@ -170,9 +170,9 @@ You will use this session to run a third NATS subscriber.
All the but last subscriber receives the message. Why? Because that subscriber is not listening on the message subject used by the publisher.
## 17. Update the last subscriber to use a wildcard
### 17. Update the last subscriber to use a wildcard
NATS supports the use of wildcard characters for message subscribers. (You cannot publish a message using a wildcard subject.)
NATS supports the use of wildcard characters for message subscribers. You cannot publish a message using a wildcard subject.
Change the last subscriber the listen on msg.* and run it:
@@ -180,6 +180,6 @@ Change the last subscriber the listen on msg.* and run it:
% go run nats-sub.go msg.*
```
## 18. Publish another message
### 18. Publish another message
This time, all three subscribing clients should receive the message.

View File

@@ -6,13 +6,13 @@ NATS supports a form of load balancing using queue groups. Subscribers register
Go and the NATS server should be installed.
## 1. Start the NATS server
### 1. Start the NATS server
```sh
nats-server
```
## 2. Clone the repositories for each client examples
### 2. Clone the repositories for each client examples
```sh
go get github.com/nats-io/go-nats
@@ -20,14 +20,14 @@ git clone https://github.com/nats-io/node-nats.git
git clone https://github.com/nats-io/ruby-nats.git
```
## 3. Run the Go client subscriber with queue group name
### 3. Run the Go client subscriber with queue group name
```sh
cd $GOPATH/src/github.com/nats-io/go-nats/examples
go run nats-qsub.go foo my-queue
```
## 4. Install and run the Node client subscriber with queue group name
### 4. Install and run the Node client subscriber with queue group name
```sh
npm install nats
@@ -35,34 +35,34 @@ cd node-nats/examples
node node-sub foo my-queue
```
## 5. Install and run the Ruby client subscriber with queue group name
### 5. Install and run the Ruby client subscriber with queue group name
```sh
gem install nats
nats-queue foo my-queue &
```
**6. Run another Go client subscriber *without* the queue group.
### 6. Run another Go client subscriber *without* the queue group.
```sh
cd $GOPATH/src/github.com/nats-io/go-nats/examples
go run nats-sub.go foo
```
## 7. Publish a NATS message using the Go client
### 7. Publish a NATS message using the Go client
```sh
cd $GOPATH/src/github.com/nats-io/go-nats/examples
go run nats-pub.go foo "Hello NATS!"
```
## 8. Verify message publication and receipt
### 8. Verify message publication and receipt
You should see that the publisher sends the message: *Published [foo] : 'Hello NATS!'*
You should see that only one of the my-queue group subscribers receives the message. In addition, the Go client subscriber not in the my-queue group should also receive the message.
## 9. Publish another message
### 9. Publish another message
```sh
go run nats-pub.go foo "Hello NATS Again!"

View File

@@ -6,23 +6,23 @@ NATS supports request/reply messaging. In this tutorial you explore how to excha
Go and the NATS server should be installed.
## 1. Start the NATS server
### 1. Start the NATS server
```sh
% nats-server
```
## 2. Start two terminal sessions
### 2. Start two terminal sessions
You will use these sessions to run the NATS request and reply clients.
## 3. Change to the examples directory
### 3. Change to the examples directory
```sh
% cd $GOPATH/src/github.com/nats-io/nats/examples
```
## 4. In one terminal, run the reply client listener
### 4. In one terminal, run the reply client listener
```sh
% go run nats-rply.go foo "this is my response"
@@ -30,7 +30,7 @@ You will use these sessions to run the NATS request and reply clients.
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.
## 5. In the other terminal, run the request client
### 5. In the other terminal, run the request client
```sh
% go run nats-req.go foo "request payload"