-
Notifications
You must be signed in to change notification settings - Fork 233
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
41 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
from aiokafka import AIOKafkaConsumer | ||
import asyncio | ||
|
||
loop = asyncio.get_event_loop() | ||
|
||
async def consume(): | ||
consumer = AIOKafkaConsumer( | ||
"my_topic", loop=loop, bootstrap_servers='localhost:9092') | ||
# Get cluster layout and topic/partition allocation | ||
await consumer.start() | ||
try: | ||
async for msg in consumer: | ||
print(msg.value) | ||
finally: | ||
await consumer.stop() | ||
|
||
loop.run_until_complete(consume()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
from aiokafka import AIOKafkaProducer | ||
import asyncio | ||
|
||
loop = asyncio.get_event_loop() | ||
|
||
async def send_one(): | ||
producer = AIOKafkaProducer( | ||
loop=loop, bootstrap_servers='localhost:9092') | ||
# Get cluster layout and topic/partition allocation | ||
await producer.start() | ||
try: | ||
# Produce messages | ||
await producer.send_and_wait("my_topic", b"Super message") | ||
finally: | ||
await producer.stop() | ||
|
||
loop.run_until_complete(send_one()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters