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

updating docs

This commit is contained in:
ainsley
2019-05-30 12:43:58 -05:00
parent 0ce229b29d
commit 7765f4b86a
162 changed files with 426 additions and 307 deletions

View File

@@ -2305,39 +2305,39 @@
<p>NATS supports a form of load balancing using queue groups. Subscribers register a queue group name. A single subscriber in the group is randomly selected to receive the message.</p>
<h2 id="prerequisites"><a name="prerequisites" class="plugin-anchor" href="#prerequisites"><i class="fa fa-link" aria-hidden="true"></i></a>Prerequisites</h2>
<p>Go and the NATS server should be installed.</p>
<h2 id="1-start-the-nats-server"><a name="1-start-the-nats-server" class="plugin-anchor" href="#1-start-the-nats-server"><i class="fa fa-link" aria-hidden="true"></i></a>1. Start the NATS server</h2>
<h3 id="1-start-the-nats-server"><a name="1-start-the-nats-server" class="plugin-anchor" href="#1-start-the-nats-server"><i class="fa fa-link" aria-hidden="true"></i></a>1. Start the NATS server</h3>
<pre class="language-"><code class="lang-sh">nats-server
</code></pre>
<h2 id="2-clone-the-repositories-for-each-client-examples"><a name="2-clone-the-repositories-for-each-client-examples" class="plugin-anchor" href="#2-clone-the-repositories-for-each-client-examples"><i class="fa fa-link" aria-hidden="true"></i></a>2. Clone the repositories for each client examples</h2>
<h3 id="2-clone-the-repositories-for-each-client-examples"><a name="2-clone-the-repositories-for-each-client-examples" class="plugin-anchor" href="#2-clone-the-repositories-for-each-client-examples"><i class="fa fa-link" aria-hidden="true"></i></a>2. Clone the repositories for each client examples</h3>
<pre class="language-"><code class="lang-sh">go get github.com/nats-io/go-nats
<span class="token function">git</span> clone https://github.com/nats-io/node-nats.git
<span class="token function">git</span> clone https://github.com/nats-io/ruby-nats.git
</code></pre>
<h2 id="3-run-the-go-client-subscriber-with-queue-group-name"><a name="3-run-the-go-client-subscriber-with-queue-group-name" class="plugin-anchor" href="#3-run-the-go-client-subscriber-with-queue-group-name"><i class="fa fa-link" aria-hidden="true"></i></a>3. Run the Go client subscriber with queue group name</h2>
<h3 id="3-run-the-go-client-subscriber-with-queue-group-name"><a name="3-run-the-go-client-subscriber-with-queue-group-name" class="plugin-anchor" href="#3-run-the-go-client-subscriber-with-queue-group-name"><i class="fa fa-link" aria-hidden="true"></i></a>3. Run the Go client subscriber with queue group name</h3>
<pre class="language-"><code class="lang-sh"><span class="token function">cd</span> <span class="token variable">$GOPATH</span>/src/github.com/nats-io/go-nats/examples
go run nats-qsub.go foo my-queue
</code></pre>
<h2 id="4-install-and-run-the-node-client-subscriber-with-queue-group-name"><a name="4-install-and-run-the-node-client-subscriber-with-queue-group-name" class="plugin-anchor" href="#4-install-and-run-the-node-client-subscriber-with-queue-group-name"><i class="fa fa-link" aria-hidden="true"></i></a>4. Install and run the Node client subscriber with queue group name</h2>
<h3 id="4-install-and-run-the-node-client-subscriber-with-queue-group-name"><a name="4-install-and-run-the-node-client-subscriber-with-queue-group-name" class="plugin-anchor" href="#4-install-and-run-the-node-client-subscriber-with-queue-group-name"><i class="fa fa-link" aria-hidden="true"></i></a>4. Install and run the Node client subscriber with queue group name</h3>
<pre class="language-"><code class="lang-sh"><span class="token function">npm</span> <span class="token function">install</span> nats
<span class="token function">cd</span> node-nats/examples
node node-sub foo my-queue
</code></pre>
<h2 id="5-install-and-run-the-ruby-client-subscriber-with-queue-group-name"><a name="5-install-and-run-the-ruby-client-subscriber-with-queue-group-name" class="plugin-anchor" href="#5-install-and-run-the-ruby-client-subscriber-with-queue-group-name"><i class="fa fa-link" aria-hidden="true"></i></a>5. Install and run the Ruby client subscriber with queue group name</h2>
<h3 id="5-install-and-run-the-ruby-client-subscriber-with-queue-group-name"><a name="5-install-and-run-the-ruby-client-subscriber-with-queue-group-name" class="plugin-anchor" href="#5-install-and-run-the-ruby-client-subscriber-with-queue-group-name"><i class="fa fa-link" aria-hidden="true"></i></a>5. Install and run the Ruby client subscriber with queue group name</h3>
<pre class="language-"><code class="lang-sh">gem <span class="token function">install</span> nats
nats-queue foo my-queue <span class="token operator">&amp;</span>
</code></pre>
<p><em>*6. Run another Go client subscriber </em>without* the queue group.</p>
<h3 id="6-run-another-go-client-subscriber-without-the-queue-group"><a name="6-run-another-go-client-subscriber-without-the-queue-group" class="plugin-anchor" href="#6-run-another-go-client-subscriber-without-the-queue-group"><i class="fa fa-link" aria-hidden="true"></i></a>6. Run another Go client subscriber <em>without</em> the queue group.</h3>
<pre class="language-"><code class="lang-sh"><span class="token function">cd</span> <span class="token variable">$GOPATH</span>/src/github.com/nats-io/go-nats/examples
go run nats-sub.go foo
</code></pre>
<h2 id="7-publish-a-nats-message-using-the-go-client"><a name="7-publish-a-nats-message-using-the-go-client" class="plugin-anchor" href="#7-publish-a-nats-message-using-the-go-client"><i class="fa fa-link" aria-hidden="true"></i></a>7. Publish a NATS message using the Go client</h2>
<h3 id="7-publish-a-nats-message-using-the-go-client"><a name="7-publish-a-nats-message-using-the-go-client" class="plugin-anchor" href="#7-publish-a-nats-message-using-the-go-client"><i class="fa fa-link" aria-hidden="true"></i></a>7. Publish a NATS message using the Go client</h3>
<pre class="language-"><code class="lang-sh"><span class="token function">cd</span> <span class="token variable">$GOPATH</span>/src/github.com/nats-io/go-nats/examples
go run nats-pub.go foo <span class="token string">&quot;Hello NATS!&quot;</span>
</code></pre>
<h2 id="8-verify-message-publication-and-receipt"><a name="8-verify-message-publication-and-receipt" class="plugin-anchor" href="#8-verify-message-publication-and-receipt"><i class="fa fa-link" aria-hidden="true"></i></a>8. Verify message publication and receipt</h2>
<h3 id="8-verify-message-publication-and-receipt"><a name="8-verify-message-publication-and-receipt" class="plugin-anchor" href="#8-verify-message-publication-and-receipt"><i class="fa fa-link" aria-hidden="true"></i></a>8. Verify message publication and receipt</h3>
<p>You should see that the publisher sends the message: <em>Published [foo] : &apos;Hello NATS!&apos;</em></p>
<p>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.</p>
<h2 id="9-publish-another-message"><a name="9-publish-another-message" class="plugin-anchor" href="#9-publish-another-message"><i class="fa fa-link" aria-hidden="true"></i></a>9. Publish another message</h2>
<h3 id="9-publish-another-message"><a name="9-publish-another-message" class="plugin-anchor" href="#9-publish-another-message"><i class="fa fa-link" aria-hidden="true"></i></a>9. Publish another message</h3>
<pre class="language-"><code class="lang-sh">go run nats-pub.go foo <span class="token string">&quot;Hello NATS Again!&quot;</span>
</code></pre>
<p>You should see that a different queue group subscriber receives the message this time, chosen at random among the 3 queue group members.</p>
@@ -2384,7 +2384,7 @@ go run nats-pub.go foo <span class="token string">&quot;Hello NATS!&quot;</span>
<script>
var gitbook = gitbook || [];
gitbook.push(function() {
gitbook.page.hasChanged({"page":{"title":"Explore NATS Queueing","level":"3.8.3","depth":2,"next":{"title":"Advanced Connect and Custom Dialer in Go","level":"3.8.4","depth":2,"path":"developer/tutorials/custom_dialer.md","ref":"developer/tutorials/custom_dialer.md","articles":[]},"previous":{"title":"Explore NATS Request/Reply","level":"3.8.2","depth":2,"path":"developer/tutorials/reqreply.md","ref":"developer/tutorials/reqreply.md","articles":[]},"dir":"ltr"},"config":{"plugins":["prism","-highlight","include-html","toggle-chapters","anchors"],"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"pluginsConfig":{"prism":{"lang":{"ascii":"markup","text":"markup"}},"search":{},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"include-html":{},"fontsettings":{"theme":"white","family":"sans","size":2},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false},"anchors":{},"toggle-chapters":{}},"theme":"default","author":"The NATS Maintainers","pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"variables":{},"title":"NATS","gitbook":"*","description":"Administrative, developer and conceptual documentation for the NATS messaging system."},"file":{"path":"developer/tutorials/queues.md","mtime":"2019-05-29T16:43:54.760Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2019-05-29T16:45:48.381Z"},"basePath":"../..","book":{"language":""}});
gitbook.page.hasChanged({"page":{"title":"Explore NATS Queueing","level":"3.8.3","depth":2,"next":{"title":"Advanced Connect and Custom Dialer in Go","level":"3.8.4","depth":2,"path":"developer/tutorials/custom_dialer.md","ref":"developer/tutorials/custom_dialer.md","articles":[]},"previous":{"title":"Explore NATS Request/Reply","level":"3.8.2","depth":2,"path":"developer/tutorials/reqreply.md","ref":"developer/tutorials/reqreply.md","articles":[]},"dir":"ltr"},"config":{"plugins":["prism","-highlight","include-html","toggle-chapters","anchors"],"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"pluginsConfig":{"prism":{"lang":{"ascii":"markup","text":"markup"}},"search":{},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"include-html":{},"fontsettings":{"theme":"white","family":"sans","size":2},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false},"anchors":{},"toggle-chapters":{}},"theme":"default","author":"The NATS Maintainers","pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"variables":{},"title":"NATS","gitbook":"*","description":"Administrative, developer and conceptual documentation for the NATS messaging system."},"file":{"path":"developer/tutorials/queues.md","mtime":"2019-05-30T17:42:13.282Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2019-05-30T17:42:48.393Z"},"basePath":"../..","book":{"language":""}});
});
</script>
</div>