Skip to content

Instantly share code, notes, and snippets.

@ripienaar
Created July 17, 2020 11:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ripienaar/8aedac128dd724b49d53b85fd5072422 to your computer and use it in GitHub Desktop.
Save ripienaar/8aedac128dd724b49d53b85fd5072422 to your computer and use it in GitHub Desktop.
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)
}
}
@ripienaar
Copy link
Author

Information for Stream ORDERS

Configuration:

             Subjects: orders.>
     Acknowledgements: true
            Retention: File - WorkQueue
             Replicas: 1
       Discard Policy: Old
     Duplicate Window: 2m0s
     Maximum Messages: unlimited
        Maximum Bytes: unlimited
          Maximum Age: 0s
 Maximum Message Size: unlimited
    Maximum Consumers: unlimited

State:

            Messages: 0
               Bytes: 0 B
            FirstSeq: 0
             LastSeq: 0
    Active Consumers: 0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment