RocketMQ Python client
Project description
rocketmq-python
RocketMQ Python client
Installation
pip install rocketmq
Usage
Producer
from rocketmq.client import Producer, Message
producer = Producer('PID-XXX')
producer.set_namesrv_domain('http://onsaddr-internet.aliyun.com/rocketmq/nsaddr4client-internet')
producer.set_session_credentials('XXX', 'XXXX', 'ALIYUN')
producer.start()
msg = Message('YOUR-TOPIC')
msg.set_keys('XXX')
msg.set_tags('XXX')
msg.set_body('XXXX')
ret = producer.send_sync(msg)
print(ret.status, ret.msg_id, ret.offset)
producer.shutdown()
PushConsumer
import time
from rocketmq.client import PushConsumer
def callback(msg):
print(msg.id, msg.body)
consumer = PushConsumer('CID_XXX')
consumer.set_namesrv_domain('http://onsaddr-internet.aliyun.com/rocketmq/nsaddr4client-internet')
consumer.set_session_credentials('XXX', 'XXXX', 'ALIYUN')
consumer.subscribe('YOUR-TOPIC', callback)
consumer.start()
while True:
time.sleep(3600)
consumer.shutdown()
PullConsumer
from rocketmq.client import PullConsumer
consumer = PullConsumer('CID_XXX')
consumer.set_namesrv_domain('http://onsaddr-internet.aliyun.com/rocketmq/nsaddr4client-internet')
consumer.set_session_credentials('XXX', 'XXXX', 'ALIYUN')
consumer.start()
for msg in consumer.pull('YOUR-TOPIC'):
print(msg.id, msg.body)
consumer.shutdown()
License
This work is released under the MIT license. A copy of the license is provided in the LICENSE file.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
No source distribution files available for this release.See tutorial on generating distribution archives.
Built Distributions
File details
Details for the file rocketmq-0.2.3-py2.py3-none-manylinux1_x86_64.whl
.
File metadata
- Download URL: rocketmq-0.2.3-py2.py3-none-manylinux1_x86_64.whl
- Upload date:
- Size: 1.2 MB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.21.0 setuptools/38.2.4 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/2.7.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d706e160e1479f2f1e164d4ab5c70d6ed31c3e256b004e8e55aae523a0d74ec0 |
|
MD5 | 831f29ec22569fc342286f5fad4da40f |
|
BLAKE2b-256 | 670b528ef4ac41d6b0af6b7fe98170e54ba086a1ca404718b96684a23f2a59b2 |
File details
Details for the file rocketmq-0.2.3-py2.py3-none-macosx_10_13_x86_64.whl
.
File metadata
- Download URL: rocketmq-0.2.3-py2.py3-none-macosx_10_13_x86_64.whl
- Upload date:
- Size: 1.0 MB
- Tags: Python 2, Python 3, macOS 10.13+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.21.0 setuptools/40.6.3 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/2.7.15
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6ac2fc9e6d5d00f3ce04a6c13aeaeb2b2b044b25b0b6089bad0e4cc507b79d6f |
|
MD5 | 462b5c218971e3eea8c62fa5bc0d3110 |
|
BLAKE2b-256 | 91598eb37f8681fe7628f65421c30d2f50466eb6b659c8a8a1204ac3bae3f359 |