Skip to content

Instantly share code, notes, and snippets.

@derekcollison
Created August 24, 2018 18:58
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 derekcollison/418cc1a25c63991fc551bcf068ef6632 to your computer and use it in GitHub Desktop.
Save derekcollison/418cc1a25c63991fc551bcf068ef6632 to your computer and use it in GitHub Desktop.
Simple Queue Subscriber
// All subscriptions with the same queue name will form a queue
// group at runtime. Each message will be delivered to only one
// subscriber per queue group. You can have as many queue groups
// as you wish, and as many members in a single group as you like.
// Normal subscribers will continue to work as expected.
nc.QueueSubscribe("foo", "job_workers", func(m *Msg) {
// Do some work, then send reply.
nc.Publish(m.ReplyTo, myAnswer)
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment