Skip to content

Instantly share code, notes, and snippets.

@ninnemana
Created February 16, 2015 17:58
Show Gist options
  • Select an option

  • Save ninnemana/44c330d373638bded289 to your computer and use it in GitHub Desktop.

Select an option

Save ninnemana/44c330d373638bded289 to your computer and use it in GitHub Desktop.
package main
import (
"github.com/bitly/go-nsq"
"log"
"sync"
)
func main() {
wg := &sync.WaitGroup{}
wg.Add(1)
config := nsq.NewConfig()
q, _ := nsq.NewConsumer("goapi", "ch", config)
q.AddHandler(nsq.HandlerFunc(func(msg *nsq.Message) error {
log.Printf("Got a message(%d): %s", msg.Attempts, string(msg.Body))
return nil
}))
err := q.ConnectToNSQD("130.211.139.218:14161")
if err != nil {
log.Panic("Could not connect")
}
wg.Wait()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment