Created
September 22, 2019 09:27
-
-
Save trennepohl/60d4342dcc5725527963a52ff5d5675a to your computer and use it in GitHub Desktop.
Nats publish
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"os" | |
"github.com/nats-io/stan.go" | |
) | |
func main() { | |
sc, err := stan.Connect("test-cluster", "client1", stan.NatsURL("localhost:4222")) | |
if err != nil { | |
panic(err.Error()) | |
} | |
// Simple Synchronous Publisher | |
err = sc.Publish("novo", []byte(os.Args[1])) // does not return until an ack has been received from NATS Streaming | |
if err != nil { | |
panic(err.Error()) | |
} | |
// Close connection | |
sc.Close() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment