| | |
| | | "context" |
| | | "fmt" |
| | | "log" |
| | | "nsqclient/nsqclient" |
| | | "nsqclient/nsqcli" |
| | | "time" |
| | | ) |
| | | |
| | | func produce(two bool) { |
| | | p, _ := nsqclient.NewProducer("192.168.20.108:4150") |
| | | p, _ := nsqcli.NewProducer("192.168.20.108:4150") |
| | | |
| | | var str string |
| | | for len(str) < 32 { |
| | | str += "cnsqclient dynamic library" |
| | | str += "cnsqcli dynamic library" |
| | | } |
| | | msgx := []byte(str + "--x") |
| | | msgy := []byte(str + "--y") |
| | |
| | | func consume(topic, channel string) { |
| | | ctx, cancel := context.WithCancel(context.Background()) |
| | | |
| | | if c, e := nsqclient.NewNsqConsumer(ctx, topic, channel); e != nil { |
| | | if c, e := nsqcli.NewNsqConsumer(ctx, topic, channel); e != nil { |
| | | fmt.Println("NewNsqConsumer failed", e) |
| | | return |
| | | } else { |