an example of using kafka with drogon framework,
consume topic using websocket & leveraging thread in drogon loop event framework.
after the required library installed, use below scrip to configure & build
you may adjust your configuration as you need
set -e;
mkdir -p build bin logs public out;
cmake -S . -G "Ninja" -B build \
-DCMAKE_BUILD_TYPE=Debug \
-DCMAKE_CXX_STANDARD=17 \
-DCMAKE_CXX_FLAGS="-std=c++17" \
-DCMAKE_EXPORT_COMPILE_COMMANDS=1;
ln -sf build/compile_commands.json ./;
cmake --build build;-
run your kafka server using docker or systemd
-
configure & build the project
-
go to
outdir configured & build -
run
producer_ctl&backend_drogon_kafka -
use websocket request with wscat
wscat -c "http://localhost:9000/ws/stock/trade"NOTE:
- there's no interaction for end-user
- they only consume what publish by "kafka producer"
- data is using stock trade simulation depend on ratio
