Skip to content

Commit

Permalink
Add new example
Browse files Browse the repository at this point in the history
  • Loading branch information
eandersson committed Nov 25, 2018
1 parent 8faf6d7 commit c64a687
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions examples/consume_queue_until_empty.py
@@ -0,0 +1,21 @@
import logging

from amqpstorm import Connection

logging.basicConfig(level=logging.DEBUG)


def consume_until_queue_is_empty():
with Connection('127.0.0.1', 'guest', 'guest') as connection:
with connection.channel() as channel:
while True:
message = channel.basic.get('simple_queue')
if not message:
print('Queue is empty')
break
print(message.body)
message.ack()


if __name__ == '__main__':
consume_until_queue_is_empty()

0 comments on commit c64a687

Please sign in to comment.