账号密码登录
微信安全登录
微信扫描二维码登录

登录后绑定QQ、微信即可实现信息互通

手机验证码登录
找回密码返回
邮箱找回 手机找回
注册账号返回
其他登录方式
分享
  • 收藏
    X
    如何只订阅 nsq 某个 topic下的特定channel?
    100
    0

    本地环境:
    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下的数据?

    0
    打赏
    收藏
    点击回答
        全部回答
    • 0
    更多回答
    扫一扫访问手机版
    • 回到顶部
    • 回到顶部