Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Add examples.

  • Loading branch information...
commit d0a3427ef57b5b90cc8259f002b33f3f2aab60f7 1 parent d0aec11
Dan Sully authored February 18, 2011
10  examples/batch
... ...
@@ -0,0 +1,10 @@
  1
+#!/usr/bin/env python
  2
+
  3
+import kafka
  4
+
  5
+producer = kafka.producer.Producer('test')
  6
+
  7
+with producer.batch() as messages:
  8
+  print "Batching a send of multiple messages.."
  9
+  messages.append(kafka.message.Message("first message to send"))
  10
+  messages.append(kafka.message.Message("second message to send"))
9  examples/consume-iter
... ...
@@ -0,0 +1,9 @@
  1
+#!/usr/bin/env python
  2
+
  3
+import kafka.consumer
  4
+
  5
+consumer = kafka.consumer.Consumer('test')
  6
+#messages = consumer.consume()
  7
+
  8
+for message in consumer.loop():
  9
+  print message
8  examples/consume-loop
... ...
@@ -0,0 +1,8 @@
  1
+#!/usr/bin/env python
  2
+
  3
+import kafka
  4
+
  5
+consumer = kafka.consumer.Consumer('test')
  6
+
  7
+for message in consumer.consume():
  8
+  print message
11  examples/produce
... ...
@@ -0,0 +1,11 @@
  1
+#!/usr/bin/env python
  2
+
  3
+import kafka
  4
+import time
  5
+
  6
+producer = kafka.producer.Producer('test')
  7
+message1 = kafka.message.Message("some random message content?")
  8
+message2 = kafka.message.Message("foo!")
  9
+message3 = kafka.message.Message(time.time())
  10
+
  11
+producer.send([message1, message2, message3])

0 notes on commit d0a3427

Please sign in to comment.
Something went wrong with that request. Please try again.