README.md 1.7 KB
Newer Older
1 2 3
librdkafka - Apache Kafka C client library
==========================================

M
Magnus Edenhill 已提交
4
Copyright (c) 2012-2013, [Magnus Edenhill](http://www.edenhill.se/), et.al.
5 6 7

[https://github.com/edenhill/librdkafka](https://github.com/edenhill/librdkafka)

M
Magnus Edenhill 已提交
8 9 10
[![endorse](http://api.coderwall.com/edenhill/endorsecount.png)](http://coderwall.com/edenhill)


11 12 13
**librdkafka** is a C implementation of the
[Apache Kafka](http://incubator.apache.org/kafka/) protocol, containing both
Producer and Consumer support.
M
Magnus Edenhill 已提交
14 15
It currently supports Apache Kafka version 0.7.* (and possibly earlier), version 0.8 support will be available Q2 2013.
**librdkafka** has been in use in production since 2012.
16 17 18 19 20

ZooKeeper integration is planned but currently not available.

**librdkafka** is licensed under the 2-clause BSD license.

M
Magnus Edenhill 已提交
21 22
And finally, dont hesitate to tell me if you are using librdkafka.

23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77

# Usage

## Requirements
	The GNU toolchain
   	pthreads
	zlib

## Instructions

### Building

      make all
      make install
      # or to install in another location than /usr/local:
      PREFIX=/my/prefix make install


### Usage in code

See `examples/rdkafka_example.c` for full examples of both
producer and consumer sides.


      #include <librdkafka/rdkafka.h>

      ..

      rd_kafka_t *rk;

      rk = rd_kafka_new_consumer(broker, topic, partition, 0, &conf)

      while (run) {      
          rko = rd_kafka_consume(rk, RD_POLL_INFINITE);
          if (rko->rko_err)
            ..errhandling..
          else if (rko->rko_len)
            handle_message(rko->rko_payload, rko->rko_len);
      }

      rd_kafka_destroy(rk);

    

Link your program with `-lrdkafka -lz -lpthread -lrt`.


## Documentation

The API is documented in `rdkafka.h`

## Examples

See the `examples/`sub-directory.

M
Magnus Edenhill 已提交
78