验证 MQ 生产消费,安装 rocketmq-client-python

许胡非
2023-12-01

一、文档目的

用于自助排查 MQ 问题,确认 MQ 服务端是否正常。

二、测试方式

在应用客户端机器上运行以下脚本,观察生产和消费是否正常。

2.1、发送消息
/usr/local/python3/bin/python3 test_mq_producer.py
2.2、消费消息
/usr/local/python3/bin/python3 test_mq_consumer.py

三、安装参考(如果已有环境,可忽略这一步骤)

3.1、python3 环境

yum -y install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gdbm-devel db4-devel libpcap-devel xz-devel libffi-dev libffi-devel

cd /data/soft/
tar -zxvf Python-3.7.12.tar.gz
cd Python-3.7.12
./configure --prefix=/usr/local/python3
make && make install
ln -s /usr/local/python3/bin/python3 /usr/bin/python3

python3 -V

3.2、安装 rocketmq-client-python

(1)安装依赖

https://github.com/apache/rocketmq-client-python
https://github.com/apache/rocketmq-client-cpp/releases/download/2.0.0/rocketmq-client-cpp-2.0.0-centos7.x86_64.rpm

cd /data/soft/
rpm -ivh rocketmq-client-cpp-2.0.0-centos7.x86_64.rpm
ln -s /usr/local/lib/librocketmq.so /usr/lib
sudo ldconfig

(2)安装 rocketmq python 客户端

下载 https://pypi.org/project/rocketmq/#files

cd /data/soft/
cd rocketmq-0.4.4
/usr/local/python3/bin/python3 setup.py install
 类似资料: