GithubHelp home page GithubHelp logo

mindis / kafka-basic Goto Github PK

View Code? Open in Web Editor NEW

This project forked from hoppity/kafka-basic

0.0 2.0 0.0 154 KB

A super-simple .NET API for Kafka over the top of microsoft/kafkanet

License: Apache License 2.0

C# 97.03% PowerShell 2.97%

kafka-basic's Introduction

kafka-basic

A basic .NET API over the top of microsoft/kafkanet that lets you get up and going with Kafka quickly and easily.

Kafka.Basic Library

This is a simplified API for using KafkaNET.

Check out Test.Consumer/HighLevelConsumer.cs, Test.Consumer/SimpleConsumer.cs and Producer/Program.cs for actual usage...

High Level (Balanced) Consumer

using (var client = new KafkaClient(zkConnect))
{
    var consumerGroup = client.Consumer(groupName);
    using (var instance = consumerGroup.Join())
    {
        instance.Subscribe(topicName)
            .Data(message =>
            {
                // Do something with message...
            })
            .Start()
            .Block(); // Block the thread from disposing everything
    }
}

Simple Consumer

using (var client = new KafkaClient(zkConnect))
using (var consumer = client.SimpleConsumer())
{
    consumer.Subscribe(topicName, partition, offset)
        .Data(message =>
        {
            // Do something with message...
        })
        .Start()
        .Block(); // Block the thread from disposing everything
}

High Level Producer

using (var client = new KafkaClient(zkConnect))
using (var topic = client.Topic(topicName))
{
    topic.Send(batch);
}

Consumer Tests

Fires up a consumer and listens for messages with timestamps.

# high-level (load balanced) consumer
.\Consumer.exe balanced -z [zookeeper_connection] -g [group_name] -t [topic_name]

# simple consumer
.\Consumer.exe simple -z [zookeeper_connection] -t [topic_name] -p [partition]

Output

***** Timers - 2016-03-28T04:27:33.9723Z *****

    [Consumer] Received
   Active Sessions = 0
             Count = 259430 Events
        Mean Value = 7388.04 Events/s
     1 Minute Rate = 5797.24 Events/s
     5 Minute Rate = 4925.15 Events/s
    15 Minute Rate = 4726.25 Events/s
             Count = 259430 Events
              Last = 2.00 ms
               Min = 0.00 ms
               Max = 25.00 ms
              Mean = 1.26 ms
            StdDev = 1.07 ms
            Median = 1.00 ms
              75% <= 1.00 ms
              95% <= 2.00 ms
              98% <= 3.00 ms
              99% <= 4.00 ms
            99.9% <= 25.00 ms

Producer Tests

Fires up a Simple Producer and sends messages with timestamps.

.\Producer.exe -z [zookeeper_connection] -t [topic_name] -b [batch_size] -m [number_of_messages]

Output

***** Timers - 2016-02-27T12:45:42.1681Z *****

    [Producer] Sent
   Active Sessions = 0
             Count = 7119 Events
        Mean Value = 59.27 Events/s
     1 Minute Rate = 58.86 Events/s
     5 Minute Rate = 59.07 Events/s
    15 Minute Rate = 59.03 Events/s
             Count = 7119 Events
              Last = 0.00 ms
               Min = 0.00 ms
               Max = 16.00 ms
              Mean = 0.26 ms
            StdDev = 0.86 ms
            Median = 0.00 ms
              75% <= 0.00 ms
              95% <= 1.00 ms
              98% <= 2.00 ms
              99% <= 2.00 ms
            99.9% <= 16.00 ms

kafka-basic's People

Contributors

ducas avatar wha-deploy avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.