跳转到主要内容
本章内容64
-
01
NATS Tools
Using NATS from client application
The most common form of connecting to the NATS messaging system will be ...
10 小时前
-
02
nats
A command line utility to interact with and manage NATS.
This utility replaces various past tools that were...
1 天前
-
03
nats bench
NATS is fast and lightweight, and places a priority on performance. The
nats CLI tool can, amongst many ot...
10 小时前
-
04
nk
nk is a command line tool that generates
nkeys. NKeys are a highly secure public-key signature system base...
1 天前
-
05
nsc
NATS account configurations are built using the
nsc tool. The NSC tool allows you to:
Create and edit Oper...
10 小时前
-
06
Basics
NSC allows you to manage identities. Identities take the form of nkeys. Nkeys are a public-key signature sy...
1 天前
-
07
Streams
To share messages you publish with other accounts, you have to Export a Stream. Exports are associated with...
1 天前
-
08
Services
To share services that other accounts can reach via request reply, you have to Export a Service. Services a...
1 天前
-
09
Signing Keys
As previously discussed, NKEYs are identities, and if someone gets a hold of an account or operator nkey th...
1 天前
-
10
Revocation
NATS supports two types of revocations. Both of these are stored in the Account JWT, so that the nats-serve...
1 天前
-
11
Managed Operators
You can use
nsc to administer multiple operators. Operators can be thought of as the owners of nats-server...
1 天前
-
12
nats-top
nats-top is a top-like tool for monitoring nats-server servers.
提示
The
nats-top functionality is now avail...
10 小时前
-
13
Tutorial
You can use nats-top to monitor in realtime NATS server connections and message statistics.
Prerequisites
S...
10 小时前
-
14
Developing With NATS
Developing with NATS involves a blend of distributed application techniques, common NATS features, and libr...
1 天前
-
15
Anatomy of a NATS application
You can use NATS to exchange information with and make requests to other applications. You can also use NAT...
10 小时前
-
16
Connecting
In order for a NATS client application to connect to the NATS service, and then subscribe or publish messag...
10 小时前
-
17
Connecting to the Default Server
Some libraries also provide a special way to connect to a default url, which is generally
nats://localhost...
1 天前
-
18
Connecting to a Specific Server
The NATS client libraries can take a full URL,
nats://demo.nats.io:4222, to specify a specific server host...
1 天前
-
19
Connecting to a Cluster
When connecting to a cluster, there are a few things to think about.
Passing a URL for each cluster member ...
10 小时前
-
20
Connection Name
Connections can be assigned a name which will appear in some of the server monitoring data. This name is no...
1 天前
-
21
Authenticating with a User and Password
For this example, start the server using:
nats-server --user myname --pass password
You can encrypt passwor...
10 小时前
-
22
Authenticating with a Token
Tokens are basically random strings, much like a password, and can provide a simple authentication mechanis...
1 天前
-
23
Authenticating with an NKey
The 2.0 version of NATS server introduces a new challenge response authentication option. This challenge re...
10 小时前
-
24
Authenticating with a Credentials File
The 2.0 version of NATS server introduced the idea of decentralized authentication based on JSON Web Tokens...
10 小时前
-
25
Encrypting Connections with TLS
While authentication limits which clients can connect, TLS can be used to encrypt traffic between client/se...
10 小时前
-
26
Setting a Connect Timeout
Each library has its own, language preferred way, to pass connection options. One of the most common option...
1 天前
-
27
Ping/Pong Protocol
NATS client applications use a PING/PONG protocol to check that there is a working connection to the NATS s...
8 小时前
-
28
Turning Off Echo'd Messages
By default a NATS connection will echo messages if the connection also has interest in the published subjec...
8 小时前
-
29
Miscellaneous functionalities
This section contains miscellaneous functionalities and options for connect.
Get the Maximum Payload Size
W...
1 天前
-
30
Automatic Reconnections
All the client libraries maintained on the nats.io GitHub page will automatically attempt to re-connect if ...
10 小时前
-
31
Disabling Reconnect
You can disable automatic reconnect with connection options:
Go
// Disable reconnect attempts
nc, err := na...
1 天前
-
32
Set the Number of Reconnect Attempts
Applications can set the maximum reconnect attempts per server. This includes the server provided to the cl...
10 小时前
-
33
Avoiding the Thundering Herd
When a server goes down, there is a possible anti-pattern called the Thundering Herd where all of the clien...
1 天前
-
34
Pausing Between Reconnect Attempts
It doesn’t make much sense to try to connect to the same server over and over. To prevent this sort of thra...
10 小时前
-
35
Listening for Reconnect Events
Because reconnect is primarily under the covers, many libraries provide an event listener you can use to be...
1 天前
-
36
Buffering Messages During Reconnect Attempts
The Core NATS client libraries try as much as possible to be fire and forget, and you should use JetStream ...
1 天前
-
37
Monitoring the Connection
Managing the interaction with the server is primarily the job of the client library but most of the librari...
1 天前
-
38
Listen for Connection Events
While the connection status is interesting, it is perhaps more interesting to know when the status changes....
1 天前
-
39
Slow Consumers
NATS is designed to move messages through the server quickly. As a result, NATS depends on the applications...
10 小时前
-
40
Receiving Messages
In general, applications can receive messages asynchronously or synchronously. Receiving messages with NATS...
1 天前
-
41
Synchronous Subscriptions
Synchronous subscriptions require the application to wait for messages. This type of subscription is easy t...
1 天前
-
42
Asynchronous Subscriptions
Asynchronous subscriptions use callbacks of some form to notify an application when a message arrives. Thes...
1 天前
-
43
Unsubscribing
The client libraries provide a means to unsubscribe a previous subscription request.
This process requires ...
1 天前
-
44
Unsubscribing After N Messages
NATS provides a special form of unsubscribe that is configured with a message count and takes effect when t...
1 天前
-
45
Replying to a Message
Incoming messages have an optional reply-to field. If that field is set, it will contain a subject to which...
1 天前
-
46
Wildcard Subscriptions
There is no special code to subscribe with a wildcard subject. Wildcards are a normal part of the subject n...
1 天前
-
47
Queue Subscriptions
Subscribing to a queue group is only slightly different than subscribing to a subject alone. The applicatio...
8 小时前
-
48
Draining Messages Before Disconnect
This feature is the ability to drain connections or subscriptions and then close the connection. Closing a ...
1 天前
-
49
Receiving Structured Data
Client libraries may provide tools to help receive structured data, like JSON. The core traffic to the NATS...
1 天前
-
50
Sending Messages
NATS sends and receives messages using a protocol that includes a target subject, an optional reply subject...
1 天前
-
51
Including a Reply Subject
The optional reply-to field when publishing a message can be used on the receiving side to respond. The rep...
1 天前
-
52
Request-Reply Semantics
The pattern of sending a message and receiving a response is encapsulated in most client libraries into a r...
1 天前
-
53
Caches, Flush and Ping
For performance reasons, most if not all, of the client libraries will buffer outgoing data so that bigger ...
10 小时前
-
54
Sending Structured Data
Some client libraries provide helpers to send structured data while others depend on the application to per...
1 天前
-
55
Building Services
Recently we have agreed upon an initial specification for a services protocol so that we can add first-clas...
1 天前
-
56
JetStream
Deciding to use streaming and higher qualities of service
In modern systems, applications can expose servic...
10 小时前
-
57
JetStream Model Deep Dive
Stream Limits, Retention, and Policy
Streams store data on disk, but we cannot store all data forever, so w...
1 天前
-
58
Managing Streams and consumers
Streams and durable consumers can be defined administratively outside the application (typically using the ...
1 天前
-
59
Consumer Details
Consumers are how client applications get the messages stored in the streams. You can have many consumers o...
1 天前
-
60
Publishing to Streams
Go
func ExampleJetStream() {
nc, err := nats.Connect("localhost")
if err != nil {
log.Fatal(err)
}
//...
1 天前
-
61
Using the Key/Value Store
As the Key Value Store is built on top of the JetStream persistence layer you obtain a KeyValueManager obje...
1 天前
-
62
Using the Object Store
The Object Store allows you to store data of any (i.e. large) size by implementing a chunking mechanism, al...
1 天前
-
63
Tutorials
Tutorials are provided to give guidance on commonly used aspects of NATS.
Advanced Connect and Custom Diale...
10 小时前
-
64
Advanced Connect and Custom Dialer in Go
The Go NATS client features a CustomDialer option which allows you to customize the connection logic agains...
1 天前