install
https://github.com/apache/roc...
wget https://github.com/apache/rocketmq-client-cpp/releases/download/2.0.0/rocketmq-client-cpp-2.0.0-centos7.x86_64.rpm
sudo rpm -ivh rocketmq-client-cpp-2.0.0-centos7.x86_64.rpm
Installation
pip install rocketmq-client-python
Producer
from rocketmq.client import Producer, Message
producer = Producer('test-litx')
producer.set_name_server_address('rxxrocketmq-namesrv.sit.dexxxxm:9876')
producer.start()
msg = Message('itworkspace')
msg.set_keys('status')
msg.set_tags('json')
msg.set_body('{"alertname": "test666666666","building": "t11111tttt"}')
ret = producer.send_sync(msg)
print(ret.status, ret.msg_id, ret.offset)
producer.shutdown()
PushConsumer
import time
from rocketmq.client import PushConsumer, ConsumeStatus
def callback(msg):
print(msg.id, msg.body)
return ConsumeStatus.CONSUME_SUCCESS
consumer = PushConsumer('itworkxxxce-consumer')
consumer.set_name_server_address('red-rocketmq-namesrv.sit.devops.xixxxu.com:9876')
consumer.subscribe('itwxxce', callback)
consumer.start()
time.sleep(3)
consumer.shutdown()
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。