Last active
July 23, 2017 17:53
-
-
Save PrzemekMalak/221a79532caefa682f8e8fad103d2d15 to your computer and use it in GitHub Desktop.
Code for my blog post https://devdiaries.pl/jak-zrobic-kolejke-w-azure/
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
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