cppkafka简介
cppkafka使c++用kafka生产和消费消息变得简单。cppkafka是 rdkafka的c++封装。
环境搭载流程
查看cppkafka的github获取编译依赖
github地址:https://github.com/mfontanini/cppkafka
In order to compile cppkafka you need:
librdkafka >= 0.9.4
CMake
A compiler with good C++11 support (e.g. gcc >= 4.8). This was tested successfully on g++ 4.8.3.
The boost library.
Now, in order to build, just run:
mkdir build
cd build
cmake<OPTIONS>..
make
开始搭建环境
-
安装librdkafka
apt install librdkafka-dev -
安装cmake
apt install cmake -
安装boost
- wget https://dl.bintray.com/boostorg/release/1.69.0/source/boost_1_69_0.tar.gz
- tar -xzvf boost_1_69_0.tar.gz
- ./bootstrap.sh
- ./b2 install
- 安装cppkafka
- wget https://github.com/mfontanini/cppkafka/archive/v0.3.1.zip
- unzip v0.3.1.zip
- cppkafka目录下
-- mkdir build
-- cd build
-- cmake ../
-- make
-- make install
- sudo ldconfig
此时,就可以直接运行cppkafka/example目录下的例子,看是否可以成功消费生产消息了。
网友评论