本地环境:
testtopic下 有 两个channel: testchannel1, testchannel2,通过nsq_to_http的方式把数据消费到http接口上
e.g:
消费者1:
/usr/local/opt/nsq/bin/nsq_to_http --topic=testtopic --channel=testchannel1 --lookupd-http-address=127.0.0.1:4161 --post=http://xx.xx.xx/index.php?typ... --content-type=application/x-www-form-urlencoded
消费者2:
/usr/local/opt/nsq/bin/nsq_to_http --topic=testtopic --channel=testchannel2 --lookupd-http-address=127.0.0.1:4161 --post=http://xx.xx.xx/index.php?typ... --content-type=application/x-www-form-urlencoded
测试执行:
curl -d "hello=world&a=1" 'http://127.0.0.1:4151/pub topic=testtopic&channel=testchannel1'
结果:
http://xx.xx.xx/index.php 中 可以接收到 type=consumer2 的请求
问题:
我不管往哪个channel下push数据, 我的两个消费者都会同事接收到数据。 那我的业务逻辑就乱套了。我不明白nsq 多个channel 到底是怎么用的? 我知道应该是我使用的问题,所以请各位指导一下 如何 只消费特定 channel下的数据?
思维走入误区