main.go 793 B

123456789101112131415161718192021222324252627282930313233
  1. package main
  2. import (
  3. "log"
  4. . "app.yhyue.com/moapp/message/config"
  5. "app.yhyue.com/moapp/message/points"
  6. "github.com/nsqio/go-nsq"
  7. )
  8. func main() {
  9. // Instantiate a consumer that will subscribe to the provided channel.
  10. config := nsq.NewConfig()
  11. consumer, err := nsq.NewConsumer("jy_event", "points", config)
  12. if err != nil {
  13. log.Fatal(err)
  14. }
  15. // Set the Handler for messages received by this Consumer. Can be called multiple times.
  16. // See also AddConcurrentHandlers.
  17. consumer.AddHandler(&points.Points{})
  18. // Use nsqlookupd to discover nsqd instances.
  19. // See also ConnectToNSQD, ConnectToNSQDs, ConnectToNSQLookupds.
  20. err = consumer.ConnectToNSQLookupd(Config.Nsq.Address)
  21. if err != nil {
  22. log.Fatal(err)
  23. }
  24. // Gracefully stop the consumer.
  25. //consumer.Stop()
  26. select {}
  27. }