Created
July 17, 2020 11:01
-
-
Save ripienaar/8aedac128dd724b49d53b85fd5072422 to your computer and use it in GitHub Desktop.
This file contains 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
func main() { | |
nc, _ := nats.Connect("localhost") | |
stream := "ORDERS" | |
consumer := "NEW" | |
for { | |
msg, err := nc.Request("$JS.API.CONSUMER.MSG.NEXT."+stream+"."+consumer, 5*time.Second) | |
if err != nil { | |
fmt.Printf("pull failed, maybe no work available: %s", err) | |
continue | |
} | |
// handle msg.Data here, ie. do your work | |
// if work was completed succesfully | |
msg.Respond(nil) | |
} | |
} |
Author
ripienaar
commented
Jul 17, 2020
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment