代码改变世界

使用Python连接rocketmq获取topic里的消息

2020-06-06 17:39  白天很白≯  阅读(693)  评论(0编辑  收藏
rocketmq第三方库只支持mac和Linux,需注意!!
#*encoding=utf-8

from rocketmq.client import PullConsumer

consumer = PullConsumer('CID_XXX')

consumer.set_namesrv_addr('192.168.0.1:9876')

consumer.start()

while True:
    for msg in consumer.pull('msg-topic'):print(msg.id, msg.body)


consumer.shutdown()