| | |
| | | "log" |
| | | "nsqCli/nsqclient" |
| | | "time" |
| | | |
| | | "github.com/nsqio/go-nsq" |
| | | ) |
| | | |
| | | func produce(two bool) { |
| | |
| | | ch := make(chan struct{}) |
| | | |
| | | count := 0 |
| | | c.AddHandler(nsq.HandlerFunc(func(msg *nsq.Message) error { |
| | | c.AddHandler(func(data []byte) error { |
| | | count++ |
| | | fmt.Println("recv msg ", string(msg.Body), " size", count) |
| | | fmt.Println("recv msg ", string(data), " size", count) |
| | | if count > 999000 { |
| | | ch <- struct{}{} |
| | | } |
| | | return nil |
| | | })) |
| | | }) |
| | | // go c.Run("192.168.20.108:4150", 2) |
| | | go c.RunLookupd("192.168.20.108:4161", 2) |
| | | |
| | |
| | | } |
| | | |
| | | func Test() { |
| | | go produce(false) |
| | | go produce(true) |
| | | |
| | | // go consume("test2", "sensor01") |
| | | go consume("test2", "sensor01") |
| | | consume("test", "sensor01") |
| | | } |