mirror of
https://github.com/taigrr/nats.docs
synced 2025-01-18 04:03:23 -08:00
updating docs
This commit is contained in:
@@ -2353,10 +2353,13 @@
|
||||
|
||||
<section class="normal markdown-section">
|
||||
|
||||
<h1 id="request-reply-and-scatter-gather"><a name="request-reply-and-scatter-gather" class="plugin-anchor" href="#request-reply-and-scatter-gather"><i class="fa fa-link" aria-hidden="true"></i></a>Request-Reply and Scatter-Gather</h1>
|
||||
<p>NATS supports two flavors of request reply messaging: point-to-point or one-to-many. Point-to-point involves the fastest or first to respond. In a one-to-many exchange, you can set a limit on the number of responses the requestor may receive or use a timeout to limit on the speed of the response. One-to-many request reply is sometimes called <em>scatter gather</em>.</p>
|
||||
<p>In a request-response exchange the publish request operation publishes a message with a reply subject expecting a response on that reply subject. Many libraries allow you to use a function that will automatically wait for a response with a timeout. You can also handle that waiting process yourself.</p>
|
||||
<p>The common pattern used by the libraries is that the request creates a unique inbox and performs a request call with the inbox reply and returns the first reply received. This is optimized in the case of multiple responses by ignoring later responses automatically.</p>
|
||||
<h1 id="request-reply"><a name="request-reply" class="plugin-anchor" href="#request-reply"><i class="fa fa-link" aria-hidden="true"></i></a>Request-Reply</h1>
|
||||
<p>Request-Reply is a common pattern in modern distributed systems. A request is sent and the application either waits on the response with a certain timeout or receives a response asynchronously.
|
||||
The increased complexity of modern systems requires features such as location transparency, scale up and scale down, observability and more. Many technologies need additional components, sidecars and proxies to accomplish the complete feature set.</p>
|
||||
<p>NATS supports this pattern with its core communication mechanism, publish and subscribe. A request is published on a given subject with a reply subject, and responders listen on that subject and send responses to the reply subject. Reply subjects
|
||||
are usually a subject called an _INBOX that will be directed back to the requestor dynamically, regardless of location of either party.</p>
|
||||
<p>NATS allows multiple responders to run and form dynamic queue groups for transparent scale up. The ability for NATS applications to drain before exiting allows scale down with no requests being dropped. And since NATS is based on publish-subscribe, observability is as simple as running another application that can view requests and responses to measure latency, watch for anomalies, direct scalability and more.</p>
|
||||
<p>The power of NATS even allows multiple responses where the first response is utilized and the system efficiently discards the additional ones. This allows for a sophisticated pattern to have multiple responders reduce response latency and jitter.</p>
|
||||
<div class="graphviz"><code data-viz="dot">
|
||||
digraph nats_request_reply {
|
||||
rankdir=LR
|
||||
@@ -2432,7 +2435,7 @@ digraph nats_request_reply {
|
||||
<script>
|
||||
var gitbook = gitbook || [];
|
||||
gitbook.push(function() {
|
||||
gitbook.page.hasChanged({"page":{"title":"Request-Reply","level":"2.4","depth":1,"next":{"title":"Queue Groups","level":"2.5","depth":1,"path":"developer/concepts/queue.md","ref":"developer/concepts/queue.md","articles":[]},"previous":{"title":"Publish-Subscribe","level":"2.3","depth":1,"path":"developer/concepts/pubsub.md","ref":"developer/concepts/pubsub.md","articles":[]},"dir":"ltr"},"config":{"plugins":["prism","-sharing","-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"}},"include-html":{},"toggle-chapters":{},"anchors":{},"search":{},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"fontsettings":{"theme":"white","family":"sans","size":2},"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}},"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/concepts/reqreply.md","mtime":"2019-05-30T22:52:52.228Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2019-06-05T22:32:29.333Z"},"basePath":"../..","book":{"language":""}});
|
||||
gitbook.page.hasChanged({"page":{"title":"Request-Reply","level":"2.4","depth":1,"next":{"title":"Queue Groups","level":"2.5","depth":1,"path":"developer/concepts/queue.md","ref":"developer/concepts/queue.md","articles":[]},"previous":{"title":"Publish-Subscribe","level":"2.3","depth":1,"path":"developer/concepts/pubsub.md","ref":"developer/concepts/pubsub.md","articles":[]},"dir":"ltr"},"config":{"plugins":["prism","-sharing","-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"}},"include-html":{},"toggle-chapters":{},"anchors":{},"search":{},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"fontsettings":{"theme":"white","family":"sans","size":2},"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}},"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/concepts/reqreply.md","mtime":"2019-06-07T14:58:27.244Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2019-06-07T14:58:58.173Z"},"basePath":"../..","book":{"language":""}});
|
||||
});
|
||||
</script>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user