ali-sdk / ali-ons

Aliyun Open Notification Service Client
MIT License
151 stars 43 forks source link

请问用这个sdk 如何消费事件,有例子可以提供参考么 #12

Closed leoliew closed 6 years ago

leoliew commented 7 years ago

看example 只看到订阅消息,没看到如何消费

wilderchen commented 7 years ago

我也遇到同样的问题,求解。

leoliew commented 7 years ago

@wilderchen 现在用上生产环境了么

wilderchen commented 7 years ago

刚决定弃用。

gxcsoccer commented 7 years ago

订阅完了,就消费了

consumer.subscribe('you-topic', '*', function*(msg) {
  // 这里放你的消费逻辑,这里不报错就认为消费完了

});
gxcsoccer commented 7 years ago

egg 里面可以使用 egg-ons 插件,消费更简单

gxcsoccer commented 7 years ago

@wilderchen 现在阿里内部也是用的这个模块,只是不需要鉴权

JacksonTian commented 6 years ago

我猜他问的就是 .done() 的问题

leoliew commented 6 years ago

对,没有 done的方法,现在转用 rabbitmq 了 ,文档比较全

leoliew commented 6 years ago

如果要对node的用户商业化,建议提供比较完善的文档资料

nswbmw commented 6 years ago

@gxcsoccer

场景:

  1. consumer 启动,发送 topicA + tagA,能收到消息

    consumer.subscribe('topicA', 'tagA', function * (msg) {
    ...
    })
  2. consumer 停掉,发送 topicA + tagA,启动 consumer 也能收到消息

    consumer.subscribe('topicA', 'tagA', function * (msg) {
    ...
    })
  3. consumer 停掉,发送 topicA + tagA,启动 consumer(如下:topicA + tagB) 收不到消息,符合预期

    consumer.subscribe('topicA', 'tagB', function * (msg) {
    ...
    })

    改回 tagA 启动,收不到消息,改成 * 也收不到

    consumer.subscribe('topicA', 'tagA', function * (msg) {
    ...
    })
    consumer.subscribe('topicA', '*', function * (msg) {
    ...
    })

什么原理??

gxcsoccer commented 6 years ago

对,没有 done的方法,现在转用 rabbitmq 了 ,文档比较全

@leoliew done 的问题参考这里的的讨论 https://github.com/eggjs/egg/issues/1468

tsui66 commented 6 years ago

可以参考这个, https://github.com/Quinton/egg-kafkajs