Disabling Reconnect
You can disable automatic reconnect with connection options:
// Disable reconnect attempts
nc, err := nats.Connect("demo.nats.io", nats.NoReconnect())
if err != nil {
log.Fatal(err)
}
defer nc.Close()
// Do something with the connectionOptions options = new Options.Builder().
server("nats://demo.nats.io:4222").
noReconnect(). // Disable reconnect attempts
build();
Connection nc = Nats.connect(options);
// Do something with the connection
nc.close();llet nc = NATS.connect({
reconnect: false,
servers: ["nats://demo.nats.io:4222"]
});最后更新于
这有帮助吗?