Skip to content

Instantly share code, notes, and snippets.

@PrzemekMalak
Last active July 23, 2017 17:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save PrzemekMalak/221a79532caefa682f8e8fad103d2d15 to your computer and use it in GitHub Desktop.
Save PrzemekMalak/221a79532caefa682f8e8fad103d2d15 to your computer and use it in GitHub Desktop.
from azure.storage.queue import QueueService
# tworzymy usługę
queue_service = QueueService(account_name='nazwa konta', account_key='klucz api')
# tworzymy kolejkę
queue_service.create_queue('testqueue')
# wysyłamy jedną wiadomość, która zniknie po 30 sekundach
# queue_service.put_message('testqueue', 'Moja pierwsza wiadomość', 0, 30, 30)
# wysyłamy pięć wiadomości
# for i in range(1, 6):
# queue_service.put_message('testqueue', 'Message No {0}'.format(i))
# podglądamy wiadomości
# messages = queue_service.peek_messages('testqueue')
# for m in messages:
# print(m.content)
# pobieramy jedną wiadomość
# messages = queue_service.get_messages('testqueue')
# pobieramy dwie wiadomości i "chowamy je" na 60 sekund
# messages = queue_service.get_messages('testqueue', 2, 60)
# for m in messages:
# print(m.content)
# pobieramy i kasujemy 2 wiadomości
# messages = queue_service.get_messages('testqueue', 2)
# for m in messages:
# print(m.content)
# queue_service.delete_message('testqueue', m.id, m.pop_receipt)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment