mirror of
https://github.com/Telecominfraproject/wlan-cloud-lib-cppkafka.git
synced 2025-11-02 03:28:01 +00:00
Update README.md
This commit is contained in:
26
README.md
26
README.md
@@ -8,29 +8,38 @@ High level C++ wrapper for _rdkafka_
|
||||
|
||||
# Features
|
||||
|
||||
* _cppkafka_ is a high level C++ wrapper for _rdkafka_, aiming at allowing to use _rdkafka_ in a simple, less error prone way.
|
||||
* _cppkafka_ is a high level C++ wrapper for _rdkafka_, aiming at allowing to use _rdkafka_ in a
|
||||
simple, less error prone way.
|
||||
|
||||
* _cppkafka_ provides an API to produce messages as well as consuming messages but the latter is only supported via the high level consumer API (introduced on kafka 0.9). Therefore, you need **rdkakfa >= 0.9** in order to use it. Other wrapped functionalities are also provided, like fetching metadata, offsets, etc.
|
||||
* _cppkafka_ provides an API to produce messages as well as consuming messages, but the latter is
|
||||
only supported via the high level consumer API. _cppkafka_ requires **rdkakfa >= 0.9.1** in
|
||||
order to use it. Other wrapped functionalities are also provided, like fetching metadata,
|
||||
offsets, etc.
|
||||
|
||||
# It's simple!
|
||||
|
||||
_cppkafka_'s API is simple. For example, this code creates a producer writes a message into some partition:
|
||||
_cppkafka_'s API is simple. For example, this code creates a producer writes a message into some
|
||||
partition:
|
||||
|
||||
```c++
|
||||
#include <cppkafka/producer.h>
|
||||
#include <string>
|
||||
using namespace cppkafka;
|
||||
|
||||
using namespace std;
|
||||
using namespace cppkafka;
|
||||
|
||||
int main() {
|
||||
// Create the config
|
||||
Configuration config;
|
||||
config.set("metadata.broker.list", "127.0.0.1:2181");
|
||||
|
||||
// Create the producer
|
||||
Producer producer(config);
|
||||
|
||||
// Get the topic we'll write into
|
||||
Topic topic = producer.get_topic("my_topic");
|
||||
string message = "hey there!";
|
||||
|
||||
// Produce a message!
|
||||
string message = "hey there!";
|
||||
producer.produce(topic, 0 /*partition*/, message);
|
||||
}
|
||||
```
|
||||
@@ -39,9 +48,10 @@ int main() {
|
||||
|
||||
In order to compile _cppkafka_ you need:
|
||||
|
||||
* _rdkafka >= 0.9_
|
||||
* _rdkafka >= 0.9.1_
|
||||
* _CMake_
|
||||
* A compiler with good C++11 support. This was tested successfully on _g++ 4.8.3_.
|
||||
* A compiler with good C++11 support (e.g. gcc >= 4.8). This was tested successfully on
|
||||
_g++ 4.8.3_.
|
||||
* The boost library. _cppkafka_ only requires boost.optional, which is a header only library,
|
||||
so this doesn't add any additional runtime dependencies.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user