NATS 中文文档
  • 引言
  • 发布日志
  • NATS 2.0
  • 对比 NATS
  • FAQ
  • NATS Concepts
    • What is NATS
    • Subject-Based Messaging
    • Publish-Subscribe
    • Request-Reply
    • Queue Groups
    • Acknowledgements
    • Sequence Numbers
  • Developing With NATS
    • Introduction
    • Connecting
      • Connecting to the Default Server
      • Connecting to a Specific Server
      • Connecting to a Cluster
      • Connection Name
      • Setting a Connect Timeout
      • Ping/Pong Protocol
      • Turning Off Echo'd Messages
      • Miscellaneous functionalities
    • Automatic Reconnections
      • Disabling Reconnect
      • Set the Number of Reconnect Attempts
      • Avoiding the Thundering Herd
      • Pausing Between Reconnect Attempts
      • Listening for Reconnect Events
      • Buffering Messages During Reconnect Attempts
    • Securing Connections
      • Authenticating with a User and Password
      • Authenticating with a Token
      • Authenticating with an NKey
      • Authenticating with a Credentials File
      • Encrypting Connections with TLS
    • Receiving Messages
      • Synchronous Subscriptions
      • Asynchronous Subscriptions
      • Unsubscribing
      • Unsubscribing After N Messages
      • Replying to a Message
      • Wildcard Subscriptions
      • Queue Subscriptions
      • Draining Messages Before Disconnect
      • Structured Data
    • Sending Messages
      • Including a Reply Subject
      • Request-Reply Semantics
      • Caches, Flush and Ping
      • Sending Structured Data
    • Monitoring the Connection
      • Listen for Connection Events
      • Slow Consumers
    • Tutorials
      • Explore NATS Pub/Sub
      • Explore NATS Request/Reply
      • Explore NATS Queueing
      • Advanced Connect and Custom Dialer in Go
  • NATS Server
    • Installing
    • Running
      • Windows Service
    • Clients
    • Flags
    • Configuration
      • Securing NATS
        • Enabling TLS
        • Authentication
          • Tokens
          • Username/Password
          • TLS Authentication
          • NKeys
          • Authentication Timeout
        • Authorization
        • Multi Tenancy using Accounts
        • Decentralized JWT Authentication/Authorization
          • Account lookup using Resolver
          • Memory Resolver Tutorial
          • Mixed Authentication/Authorization Setup
      • Clustering
        • Configuration
        • TLS Authentication
      • Super-cluster with Gateways
        • Configuration
      • Leaf Nodes
        • Configuration
      • Logging
      • Monitoring
      • System Events
        • System Events & Decentralized JWT Tutorial
    • Managing A NATS Server
      • Upgrading a Cluster
      • Slow Consumers
      • Signals
    • NATS and Docker
      • Tutorial
      • Docker Swarm
      • Python and NGS Running in Docker
  • NATS Tools
    • Introduction
    • mkpasswd
    • nk
    • nsc
      • Basics
      • Streams
      • Services
      • Signing Keys
      • Revocation
      • Managed Operators
    • nats-account-server
      • Basics
      • Inspecting JWTs
      • Directory Store
      • Update Notifications
    • nats-top
      • Tutorial
    • nats-bench
  • NATS Streaming Concepts
    • Introduction
    • Relation to NATS
    • Client Connections
    • Channels
      • Message Log
      • Subscriptions
        • Regular
        • Durable
        • Queue Group
        • Redelivery
    • Store Interface
    • Store Encryption
    • Clustering
      • Supported Stores
      • Configuration
      • Auto Configuration
      • Containers
    • Fault Tolerance
      • Active Server
      • Standby Servers
      • Shared State
      • Failover
    • Partitioning
    • Monitoring
      • Endpoints
  • Developing With NATS Streaming
    • Introduction
    • Connecting to NATS Streaming
    • Publishing to a Channel
    • Receiving Messages from a Channel
    • Durable Subscriptions
    • Queue Subscriptions
    • Acknowledgements
    • The Streaming Protocol
  • NATS Streaming Server
    • Important Changes
    • Installing
    • Running
    • Configuring
      • Command Line Arguments
      • Configuration File
      • Store Limits
      • 持久化
        • 文件存储
        • SQL 存储
      • Securing
    • Process Signaling
    • Windows Service
    • Embedding NATS Streaming Server
    • Docker Swarm
  • NATS Protocol
    • Protocol Demo
    • Client Protocol
      • Developing a Client
    • NATS Cluster Protocol
  • 在 Kubernetes中使用NATS
    • 序言
    • 安装 NATS 和 NATS Streaming
    • 创建一个 Kubernetes 集群
    • 容错(Fault Tolerance)模式下的NATS Streaming 集群
    • NATS 和 Prometheus Operator
    • NATS 集群和证书管理
    • 使用 cfssl 来提高 NATS 集群的安全性
    • 使用负载均衡器(Load Balancer) 为NATS提供外部访问
    • 使用Helm在Digital Ocean 创建一个NATS 超级集群
    • 使用Helm从0到 K8s到 子节点
由 GitBook 提供支持
在本页
  • General
  • Technical Questions
  • General
  • What is NATS?
  • What does the NATS acronym stand for?
  • What does STAN stand for?
  • What language is NATS written in?
  • Who maintains NATS?
  • What client support exists for NATS?
  • Technical Questions
  • What is the difference between Request() and Publish()?
  • Can multiple subscribers receive a Request?
  • How can I monitor my NATS cluster?
  • Does NATS do queuing? Does NATS do load balancing?
  • Can I list the subjects that exist in my NATS cluster?
  • Does NATS support subject wildcards?
  • What do ‘verbose’ and ‘pedantic’ mean when using CONNECT?
  • Does NATS offer any guarantee of message ordering?
  • Is there a message size limitation in NATS?
  • Does NATS impose any limits on the # of subjects?
  • Does NATS guarantee message delivery?
  • Does NATS support replay/redelivery of historical data?
  • How do I gracefully shut down an asynchronous subscriber?
  • How do I create subjects?
  • Does adding a “max_age” to a “channel” for NATS streaming server connected to a SQL store, retroactively delete messages?
  • What is the upgrade path from NATS 1.x to 2.x?

这有帮助吗?

FAQ

上一页对比 NATS下一页What is NATS

最后更新于4年前

这有帮助吗?

General

Technical Questions

General

What is NATS?

NATS is an open source, lightweight, high-performance cloud native infrastructure messaging system. It implements a highly scalable and elegant publish-subscribe (pub/sub) distribution model. The performant nature of NATS make it an ideal base for building modern, reliable, scalable cloud native distributed systems.

What does the NATS acronym stand for?

NATS stands for Neural Autonomic Transport System. Derek Collison conceived NATS as a messaging platform that functions like a central nervous system.

What does STAN stand for?

NATS Streaming is also known as STAN, which is just NATS backward. NATS is at-most-once QoS messaging with no persistence, whereas NATS Streaming is at-least-once QoS, therefore, representing the opposite of NATS.

What language is NATS written in?

Who maintains NATS?

What client support exists for NATS?

Technical Questions

What is the difference between Request() and Publish()?

Publish() sends a message to nats-server with a subject as its address, and nats-server delivers the message to any interested/eligible subscriber of that subject. Optionally, you may also send along a reply subject with your message, which provides a way for subscribers who have received your message(s) to send messages back to you.

Request() is simply a convenience API that does this for you in a pseudo-synchronous fashion, using a timeout supplied by you. It creates an INBOX (a type of subject that is unique to the requestor), subscribes to it, then publishes your request message with the reply address set to the inbox subject. It will then wait for a response, or the timeout period to elapse, whichever comes first.

Can multiple subscribers receive a Request?

Yes. NATS is a publish and subscribe system that also has distributed queueing functionality on a per subscriber basis. When you publish a message, for instance at the beginning of a request, every subscriber will receive the message. If subscribers form a queue group, only one subscriber will be picked at random to receive the message. However, note that the requestor does not know or control this information. What the requestor does control is that it only wants one answer to the request, and NATS handles this very well by actively pruning the interest graph.

How can I monitor my NATS cluster?

Does NATS do queuing? Does NATS do load balancing?

The term 'queueing' implies different things in different contexts, so we must be careful with its use. NATS implements non-persistent distributed queuing via subscriber queue groups. Subscriber queue groups offer a form of message-distribution load balancing. Subject subscriptions in NATS may be either 'individual' subscriptions or queue group subscriptions. The choice to join a queue group is made when the subscription is created, by supplying an optional queue group name. For individual subject subscribers, nats-server will attempt to deliver a copy of every message published to that subject to every eligible subscriber of that subject. For subscribers in a queue group, nats-server will attempt to deliver each successive message to exactly one subscriber in the group, chosen at random.

This form of distributed queueing is done in real time, and messages are not persisted to secondary storage. Further, the distribution is based on interest graphs (subscriptions), so it is not a publisher operation, but instead is controlled entirely by nats-server.

Can I list the subjects that exist in my NATS cluster?

NATS maintains and constantly updates the interest graph (subjects and their subscribers) in real time. Do not think of it as a "directory" that is aggregated over time. The interest graph is dynamic, and will change constantly as publishers and subscribers come and go.

Does NATS support subject wildcards?

Yes. The valid wildcards are as follows:

The dot character '.' is the token separator.

The asterisk character '*' is a token wildcard match.

 e.g foo.* matches foo.bar, foo.baz, but not foo.bar.baz.

The greater-than symbol '>' is a full wildcard match.

e.g. foo.> matches foo.bar, foo.baz, foo.bar.baz, foo.bar.1, etc.

What do ‘verbose’ and ‘pedantic’ mean when using CONNECT?

‘Verbose’ means all protocol commands will be acked with a +OK or -ERR. If verbose is off, you don't get the +OK for each command. Pedantic means the server does lots of extra checking, mostly around properly formed subjects, etc. Verbose mode is ON by default for new connections; most client implementations disable verbose mode by default in their INFO handshake during connection.

Does NATS offer any guarantee of message ordering?

NATS implements source ordered delivery per publisher. That is to say, messages from a given single publisher will be delivered to all eligible subscribers in the order in which they were originally published. There are no guarantees of message delivery order amongst multiple publishers.

Is there a message size limitation in NATS?

NATS does have a message size limitation that is enforced by the server and communicated to the client during connection setup. Currently, the limit is 1MB.

Does NATS impose any limits on the # of subjects?

No. As of nats-server v0.8.0, there is no hard limit on the maximum number of subjects.

Does NATS guarantee message delivery?

  • NATS implements what is commonly referred to as "at-most-once" delivery. This means that messages are guaranteed to arrive intact, in order from a given publisher, but not across different publishers. NATS does everything required to remain on and provide a dial-tone. However, if a subscriber is problematic or goes offline it will not receive messages, as the basic NATS platform is a simple pub-sub transport system that offers only TCP reliability.

Does NATS support replay/redelivery of historical data?

How do I gracefully shut down an asynchronous subscriber?

To gracefully shutdown an asynchronous subscriber so that any outstanding MsgHandlers have a chance to complete outstanding work, call sub.Unsubscribe(). There is a Go routine per subscription. These will be cleaned up on Unsubscribe(), or upon connection teardown.

How do I create subjects?

Subjects are created and pruned (deleted) dynamically based on interest (subscriptions). This means that a subject does not exist in a NATS cluster until a client subscribes to it, and the subject goes away after the last subscribing client unsubscribes from that subject.

Does adding a “max_age” to a “channel” for NATS streaming server connected to a SQL store, retroactively delete messages?

What is the upgrade path from NATS 1.x to 2.x?

NATS is offered in two interoperable modules: core NATS (referred to simply as "NATS" or "NATS Server" throughout this site), and , an event streaming service that can be employed to add event streaming, delivery guarantees, and historical data replay to NATS.

NATS was created by Derek Collison, who has over 25 years of experience designing, building, and using publish-subscribe messaging systems. NATS is maintained by an amazing OpenSource Ecosystem, find more at .

The NATS server (nats-server) is written in Go. There is client support for a wide variety of languages. Please see the page for more info.

NATS is maintained by a select group of Maintainers following a Governance process as part of the . The team of engineers at in conjunction with Community Maintainers, maintain the NATS server, NATS Streaming Server, as well as the official Go, Ruby, Node.js, C, C#, Java and several other client libraries. Our very active user community also contributes client libraries and connectors for several other implementation languages. Please see the page for the complete list, and links to the relevant source repositories and documentation.

Please see the page for the latest list of Synadia and Community maintained NATS clients.

NATS can be deployed to have an HTTP(s) monitoring port - see the demo server here: . Alternately, there are several options available, including some from the active NATS community:

Use Prometheus to configure metrics and Grafana to create a visual display.

A top-like monitoring tool developed by Wally Quevedo of Synadia.

A monitoring tool developed by Fatih Cetinkaya.

A monitoring tool developed by Raül Pérez and Adrià Cidre.

A more detailed overview of monitoring is available under .

If you are determined to gather this information, it can be indirectly derived at any instant in time by polling the monitoring endpoint for /connz and /routez. See for more information.

NATS is offered as two components: the core server (referred to simply as "NATS" or "NATS Server") and , which is a data streaming service that sits atop NATS core like a client.

offers at-least-once delivery guarantees by implementing publish and delivery acknowledgements, and persisting messages to memory or a secondary store until messages have been successfully delivered, or until resource limits or other administrator-defined limits have been reached.

Yes, historical data may be persisted to memory or secondary storage and replayed using , an event streaming service based on (and compatible with) NATS.

Yes, any channel limit will be applied on startup. For more information, see .

NATS 2.0 is completely backwards compatible with NATS < 2.x configure files and clients. Just run the new server. Be sure to review the for great new features.

NATS Streaming
GitHub
Download
Cloud Native Computing Foundation (CNCF)
Synadia
download
Download
http://demo.nats.io:8222/
Prometheus NATS Exporter
nats-top
natsboard
nats-mon
NATS Server Monitoring
Server Monitoring
NATS Streaming
NATS Streaming
NATS Streaming
What's New in 2.0
What is NATS?
What language is NATS written in?
Who maintains NATS?
What clients does NATS support?
What does the NATS acronym stand for?
What does STAN stand for?
What is the difference between Request() and Publish()?
Can multiple subscribers receive a Request?
How can I monitor my NATS cluster?
Does NATS do queuing? Does NATS do load balancing?
Can I list the subjects that exist in my NATS cluster?
Does NATS support subject wildcards?
What do ‘verbose’ and ‘pedantic’ mean when using CONNECT?
Does NATS offer any guarantee of message ordering?
Is there a message size limitation in NATS?
Does NATS impose any limits on the # of subjects?
Does NATS guarantee message delivery?
Does NATS support replay/redelivery of historical data?
How do I gracefully shut down an asynchronous subscriber?
How do I create subjects?
Does adding a “max_age” to a “channel” for NATS streaming server connected to a SQL store, retroactively delete messages?
What is the upgrade path from NATS 1.x to 2.x?
Store Limits