- python 2.7.x
- CPP Core: librocketmq
- python-devel 2.7.x
- boost-python 1.58.0
-
Install compile tools:
- sudo yum install make - sudo yum install cmake - sudo yum install gcc-c++ -
Install dependency:
-
python-devel
sudo yum install python-devel -
zlib-devel
sudo yum install zlib-devel -
boost-python
sudo sh install_boostpython.sh -
librocketmq, choose one method below:
-
build from source: Build and Install
-
download specific release: rocketmq-client-cpp and unzip the package, please choose the right version according to your OS and unzip it, then copy the library files to to your
/usr/local/lib/directory and copy the head files underincludepath to/usr/local/include/rocketmq/. and please make sure your/usr/local/lib/directory is under theLD_LIBRARY_PATH.
-
-
-
Make and install module manually
-
Using Dynamic RocketMQ and boost python libraries are recommended.
- mkdir build && cd build - cmake ../ -DBoost_USE_STATIC_LIBS=OFF -DROCKETMQ_USE_STATIC_LIBS=OFF - make - make install -
Also you can using static libraries.
- mkdir build & cd build - cmake ../ -DBoost_USE_STATIC_LIBS=ON -DROCKETMQ_USE_STATIC_LIBS=ON - make - make install
-
-
Check verion
strings librocketmqclientpython.so |grep PYTHON_CLIENT_VERSION
-
Compile tools:
- make: 3.8 - cmake 3.12 - Apple LLVM(clang) 10 -
Install dependency:
-
python-devel
-
zlib-devel
-
boost-python
sh install_boostpython.sh -
librocketmq, choose one method below:
-
build from source: Build and Install
-
quick install: there are no cpp binary release for macos, below script can only be used for dev env.
mkdir rocketmqlib cd rocketmqlib wget https://opensource-rocketmq-client.oss-cn-hangzhou.aliyuncs.com/cpp-client/mac/1.2.4/librocketmq.tar.gz tar -xzf librocketmq.tar.gz cp librocketmq.dylib librocketmq.a /usr/local/lib/ cp -r rocketmq /usr/local/include/ -
-
-
Make and install module manually
- mkdir build && cd build - cmake ../ -DBoost_USE_STATIC_LIBS=OFF -DROCKETMQ_USE_STATIC_LIBS=OFF - make - make install -
Check verion
strings librocketmqclientpython.so |grep PYTHON_CLIENT_VERSION
-
set LD_LIBRARY_PATH
export LD_LIBRARY_PATH=/usr/local/lib -
import module
from librocketmqclientpython import * -
create message by following interface:
- msg = CreateMessage("your_topic.") - SetMessageBody(msg, "this_message_body.") - SetMessageKeys(msg, "this_message_keys.") - SetMessageTags(msg, "this_message_tag.") -
producer must invoke following interface:
- producer = CreateProducer("please_rename_unique_group_name"); - SetProducerNameServerAddress(producer, "please_rename_unique_name_server") - StartProducer(producer) - SendMessageSync(producer, msg) - ShutdownProducer(producer) - DestroyProducer(producer) -
how to consumer messages
- def consumerMessage(msg, args): - topic = GetMessageTopic(msg) - body = GetMessageBody(msg) - tags = GetMessageTags(msg) - msgid = GetMessageId(msg) - # handle message... - return 0 -
pushconsumer must invoke following interface:
- consumer = CreatePushConsumer("please_rename_unique_group_name_1"); - SetPushConsumerNameServerAddress(consumer, "please_rename_unique_name_server") - Subscribe(consumer, "your_topic", "*") - RegisterMessageCallback(consumer, consumerMessage, args) - StartPushConsumer(consumer) - ShutdownPushConsumer(consumer) - DestroyPushConsumer(consumer)
- sync producer
- python testProducer.py
- push consumer
- python testConsumer.py