发送消息
nc, err := nats.Connect("demo.nats.io", nats.Name("API PublishBytes Example"))
if err != nil {
log.Fatal(err)
}
defer nc.Close()
if err := nc.Publish("updates", []byte("All is Well")); err != nil {
log.Fatal(err)
}Connection nc = Nats.connect("nats://demo.nats.io:4222");
nc.publish("updates", "All is Well".getBytes(StandardCharsets.UTF_8));
// Make sure the message goes through before we close
nc.flush(Duration.ZERO);
nc.close();const sc = StringCodec();
nc.publish("updates", sc.encode("All is Well"));nc = NATS()
await nc.connect(servers=["nats://demo.nats.io:4222"])
await nc.publish("updates", b'All is Well')最后更新于