# rocketmq-client-python
[![License](https://img.shields.io/badge/license-Apache%202-4EB1BA.svg)](https://www.apache.org/licenses/LICENSE-2.0.html)
[![Build Status](https://travis-ci.org/apache/rocketmq-client-python.svg?branch=master)](https://travis-ci.org/apache/rocketmq-client-python)
[![codecov](https://codecov.io/gh/apache/rocketmq-client-python/branch/ctypes/graph/badge.svg)](https://codecov.io/gh/apache/rocketmq-client-python/branch/ctypes)
[![PyPI](https://img.shields.io/pypi/v/rocketmq-client-python.svg)](https://pypi.org/project/rocketmq-client-python)
[![GitHub release](https://img.shields.io/badge/release-download-default.svg)](https://github.com/apache/rocketmq-client-python/releases)
[![Average time to resolve an issue](http://isitmaintained.com/badge/resolution/apache/rocketmq-client-python.svg)](http://isitmaintained.com/project/apache/rocketmq-client-python "Average time to resolve an issue")
[![Percentage of issues still open](http://isitmaintained.com/badge/open/apache/rocketmq-client-python.svg)](http://isitmaintained.com/project/apache/rocketmq-client-python "Percentage of issues still open")
![Twitter Follow](https://img.shields.io/twitter/follow/ApacheRocketMQ?style=social)
RocketMQ Python client, based on [rocketmq-client-cpp](https://github.com/apache/rocketmq-client-cpp), supports Linux and macOS
## Prerequisites
### Install `librocketmq`
rocketmq-client-python is a lightweight wrapper around [rocketmq-client-cpp](https://github.com/apache/rocketmq-client-cpp), so you need install
`librocketmq` first.
#### Download by binary release.
- debian
```bash
wget https://git.n.xiaomi.com/hankunming/RMQ-CPP-Client-Package/uploads/bd4e86d6c0ef4c65b4ef7014e8fe5c72/rocketmq-client-cpp-2.2.1.amd64.deb
sudo dpkg -i rocketmq-client-cpp-2.2.1.amd64.deb
```
- centos
```bash
wget https://git.n.xiaomi.com/hankunming/RMQ-CPP-Client-Package/uploads/1b6ac162c409ef0534eb08aa2096af1d/rocketmq-client-cpp-2.2.1-centos.x86_64.rpm
sudo rpm -ivh rocketmq-client-cpp-2.2.1-centos.x86_64.rpm
```
## Installation
```bash
pip install rocketmq-client-python-mi
```
## Usage
### Producer
```python
from rocketmq.client import Producer, Message
producer = Producer('PID-XXX')
producer.set_name_server_address('127.0.0.1:9876')
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
```python
import time
from rocketmq.client import PushConsumer, ConsumeStatus
def callback(msg):
print(msg.id, msg.body)
return ConsumeStatus.CONSUME_SUCCESS
consumer = PushConsumer('CID_XXX')
consumer.set_name_server_address('127.0.0.1:9876')
consumer.subscribe('YOUR-TOPIC', callback)
consumer.start()
while True:
time.sleep(3600)
consumer.shutdown()
```
## License
[Apache License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0.html) Copyright (C) Apache Software Foundation
Raw data
{
"_id": null,
"home_page": null,
"name": "rocketmq-client-python-mi",
"maintainer": null,
"docs_url": null,
"requires_python": null,
"maintainer_email": null,
"keywords": "rocketmq",
"author": "apache.rocketmq",
"author_email": "dev@rocketmq.apache.org",
"download_url": "https://files.pythonhosted.org/packages/da/c8/6aeb8776c8e48a260e41d41f3892371aebbd5f4553bc707cff997c8e5dd2/rocketmq-client-python-mi-1.0.2.tar.gz",
"platform": null,
"description": "# rocketmq-client-python\n\n[![License](https://img.shields.io/badge/license-Apache%202-4EB1BA.svg)](https://www.apache.org/licenses/LICENSE-2.0.html)\n[![Build Status](https://travis-ci.org/apache/rocketmq-client-python.svg?branch=master)](https://travis-ci.org/apache/rocketmq-client-python)\n[![codecov](https://codecov.io/gh/apache/rocketmq-client-python/branch/ctypes/graph/badge.svg)](https://codecov.io/gh/apache/rocketmq-client-python/branch/ctypes)\n[![PyPI](https://img.shields.io/pypi/v/rocketmq-client-python.svg)](https://pypi.org/project/rocketmq-client-python)\n[![GitHub release](https://img.shields.io/badge/release-download-default.svg)](https://github.com/apache/rocketmq-client-python/releases)\n[![Average time to resolve an issue](http://isitmaintained.com/badge/resolution/apache/rocketmq-client-python.svg)](http://isitmaintained.com/project/apache/rocketmq-client-python \"Average time to resolve an issue\")\n[![Percentage of issues still open](http://isitmaintained.com/badge/open/apache/rocketmq-client-python.svg)](http://isitmaintained.com/project/apache/rocketmq-client-python \"Percentage of issues still open\")\n![Twitter Follow](https://img.shields.io/twitter/follow/ApacheRocketMQ?style=social)\n\nRocketMQ Python client, based on [rocketmq-client-cpp](https://github.com/apache/rocketmq-client-cpp), supports Linux and macOS\n## Prerequisites\n\n### Install `librocketmq`\nrocketmq-client-python is a lightweight wrapper around [rocketmq-client-cpp](https://github.com/apache/rocketmq-client-cpp), so you need install \n`librocketmq` first.\n\n#### Download by binary release.\n\n- debian\n ```bash\n wget https://git.n.xiaomi.com/hankunming/RMQ-CPP-Client-Package/uploads/bd4e86d6c0ef4c65b4ef7014e8fe5c72/rocketmq-client-cpp-2.2.1.amd64.deb\n sudo dpkg -i rocketmq-client-cpp-2.2.1.amd64.deb\n ```\n\n- centos\n ```bash\n wget https://git.n.xiaomi.com/hankunming/RMQ-CPP-Client-Package/uploads/1b6ac162c409ef0534eb08aa2096af1d/rocketmq-client-cpp-2.2.1-centos.x86_64.rpm\n sudo rpm -ivh rocketmq-client-cpp-2.2.1-centos.x86_64.rpm\n ```\n## Installation\n\n```bash\npip install rocketmq-client-python-mi\n```\n\n## Usage\n\n### Producer\n\n```python\nfrom rocketmq.client import Producer, Message\n\nproducer = Producer('PID-XXX')\nproducer.set_name_server_address('127.0.0.1:9876')\nproducer.start()\n\nmsg = Message('YOUR-TOPIC')\nmsg.set_keys('XXX')\nmsg.set_tags('XXX')\nmsg.set_body('XXXX')\nret = producer.send_sync(msg)\nprint(ret.status, ret.msg_id, ret.offset)\nproducer.shutdown()\n```\n\n### PushConsumer\n\n```python\nimport time\n\nfrom rocketmq.client import PushConsumer, ConsumeStatus\n\n\ndef callback(msg):\n print(msg.id, msg.body)\n return ConsumeStatus.CONSUME_SUCCESS\n\n\nconsumer = PushConsumer('CID_XXX')\nconsumer.set_name_server_address('127.0.0.1:9876')\nconsumer.subscribe('YOUR-TOPIC', callback)\nconsumer.start()\n\nwhile True:\n time.sleep(3600)\n\nconsumer.shutdown()\n\n```\n\n## License\n[Apache License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0.html) Copyright (C) Apache Software Foundation\n\n\n",
"bugtrack_url": null,
"license": null,
"summary": "RocketMQ Python Client",
"version": "1.0.2",
"project_urls": null,
"split_keywords": [
"rocketmq"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "dac86aeb8776c8e48a260e41d41f3892371aebbd5f4553bc707cff997c8e5dd2",
"md5": "79695f9d94264827e3154ada789a7345",
"sha256": "1b006731a226e5776e4b17aa10d5e9f4783d345a22eb8209786816d1a4220659"
},
"downloads": -1,
"filename": "rocketmq-client-python-mi-1.0.2.tar.gz",
"has_sig": false,
"md5_digest": "79695f9d94264827e3154ada789a7345",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 15679,
"upload_time": "2024-05-27T12:29:04",
"upload_time_iso_8601": "2024-05-27T12:29:04.826422Z",
"url": "https://files.pythonhosted.org/packages/da/c8/6aeb8776c8e48a260e41d41f3892371aebbd5f4553bc707cff997c8e5dd2/rocketmq-client-python-mi-1.0.2.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-05-27 12:29:04",
"github": false,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"lcname": "rocketmq-client-python-mi"
}