Request-Reply Semantics
nc, err := nats.Connect("demo.nats.io")
if err != nil {
log.Fatal(err)
}
defer nc.Close()
// Send the request
msg, err := nc.Request("time", nil, time.Second)
if err != nil {
log.Fatal(err)
}
// Use the response
log.Printf("Reply: %s", msg.Data)
// Close the connection
nc.Close()Connection nc = Nats.connect("nats://demo.nats.io:4222");
// Send the request
Message msg = nc.request("time", null, Duration.ofSeconds(1));
// Use the response
System.out.println(new String(msg.getData(), StandardCharsets.UTF_8));
// Close the connection
nc.close();Scatter-Gather
Last updated
Was this helpful?