文件同步
選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

nsq_single_product.go 436 B

123456789101112131415161718192021222324252627282930
  1. package nsqclient
  2. import (
  3. "fmt"
  4. "github.com/nsqio/go-nsq"
  5. "time"
  6. )
  7. func main() {
  8. nsqAddr := "www.lockingos.org:4150"
  9. conf :=nsq.NewConfig()
  10. p ,err := nsq.NewProducer(nsqAddr,conf)
  11. if err != nil {
  12. fmt.Println(err)
  13. return
  14. }
  15. for {
  16. message := "message :"+ time.Now().Format("2006-01-02 15:04:05")
  17. fmt.Println(message)
  18. // 发送消息
  19. p.Publish("topic-demo1",[]byte(message))
  20. time.Sleep(2*time.Second)
  21. }
  22. }