Skip to content

Commit

Permalink
Added some more documentation to cover getting offsets.
Browse files Browse the repository at this point in the history
  • Loading branch information
spmallette committed Mar 10, 2011
1 parent a472afd commit cfb6b65
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions clients/csharp/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
# .NET Kafka Client

## Producer Usage
This is a .NET implementation of a client for Kafka using C#. It provides for a basic implementation that covers most basic functionalities to include a simple Producer and Consumer.

Exceptions are not trapped within the library and basically bubble up directly from the TcpClient and it's underlying Socket connection. Clients using this library should look to do their own exception handling.

## Producer

The Producer can send one or more messages to Kafka in both a synchronous and asynchronous fashion.

### Producer Usage

string payload1 = "kafka 1.";
byte[] payloadData1 = Encoding.UTF8.GetBytes(payload1);
Expand All @@ -13,14 +21,20 @@
Producer producer = new Producer("localhost", 9092);
producer.Send("test", 0, new List<Message> { msg1, msg2 });

## Asynchronous Producer Usage
### Asynchronous Producer Usage

List<Message> messages = GetBunchOfMessages();

Producer producer = new Producer("localhost", 9092);
producer.SendAsync("test", 0, messages, (requestContext) => { // doing work });

## Consumer Usage
## Consumer

Currently, the consumer is not terribly advanced. It has two functions of interest: `GetOffsetsBefore` and `Consume`. `GetOffsetsBefore` will retrieve a list of offsets before a given time and `Consume` will attempt to get a list of messages from Kafka given a topic, partition and offset.

### Consumer Usage

Consumer consumer = new Consumer("localhost", 9092);
List<Message> messages = consumer.Consume("test", 0, 0);
int max = 10;
long[] offsets = consumer.GetOffsetsBefore("test", 0, OffsetRequest.LatestTime, max);
List<Message> messages = consumer.Consume("test", 0, offsets[0]);

0 comments on commit cfb6b65

Please sign in to comment.