Avoiding the Thundering Herd
servers := []string{"nats://127.0.0.1:1222",
"nats://127.0.0.1:1223",
"nats://127.0.0.1:1224",
}
nc, err := nats.Connect(strings.Join(servers, ","), nats.DontRandomize())
if err != nil {
log.Fatal(err)
}
defer nc.Close()
// Do something with the connectionOptions options = new Options.Builder()
.server("nats://127.0.0.1:1222,nats://127.0.0.1:1223,nats://127.0.0.1:1224")
.noRandomize() // Disable randomizing servers in the bootstrap and later discovered
.build();
Connection nc = Nats.connect(options);
// Do something with the connection
nc.close();Last updated
Was this helpful?