Created
October 16, 2015 08:47
-
-
Save haxoza/72e19c8522202a578b09 to your computer and use it in GitHub Desktop.
Receiving messages from Azure Service Bus persistent queue
This file contains hidden or 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
import logging | |
import os | |
import traceback | |
from azure.servicebus import ServiceBusService | |
AZURE_SERVICE_BUS_NAMESPACE = os.environ['AZURE_SERVICE_BUS_NAMESPACE'] | |
AZURE_SERVICE_BUS_ACS_ISSUER = os.environ['AZURE_SERVICE_BUS_ACS_ISSUER'] | |
AZURE_SERVICE_BUS_ACS_ACCOUNT_KEY = os.environ['AZURE_SERVICE_BUS_ACS_ACCOUNT_KEY'] | |
AZURE_SERVICE_BUS_QUEUE_NAME = os.environ['AZURE_SERVICE_BUS_QUEUE_NAME'] | |
logging.basicConfig(level=logging.INFO) | |
logger = logging.getLogger(__name__) | |
service_bus = ServiceBusService( | |
service_namespace=AZURE_SERVICE_BUS_NAMESPACE, | |
issuer=AZURE_SERVICE_BUS_ACS_ISSUER, | |
account_key=AZURE_SERVICE_BUS_ACS_ACCOUNT_KEY, | |
) | |
while True: | |
try: | |
logger.info('Waiting for a message ...') | |
message = service_bus.receive_queue_message(AZURE_SERVICE_BUS_QUEUE_NAME, peek_lock=True) | |
if message and message.body: | |
logger.info('Message received: {0}'.format(message.body)) | |
message.delete() | |
except Exception: | |
traceback.print_exc() |
This file contains hidden or 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
azure==1.0.2 | |
azure-common==1.0.0 | |
azure-mgmt==0.20.1 | |
azure-mgmt-common==0.20.0 | |
azure-mgmt-compute==0.20.0 | |
azure-mgmt-network==0.20.1 | |
azure-mgmt-nspkg==1.0.0 | |
azure-mgmt-resource==0.20.1 | |
azure-mgmt-storage==0.20.0 | |
azure-nspkg==1.0.0 | |
azure-servicebus==0.20.1 | |
azure-servicemanagement-legacy==0.20.1 | |
azure-storage==0.20.2 | |
futures==3.0.3 | |
python-dateutil==2.4.2 | |
requests==2.8.0 | |
six==1.10.0 | |
wheel==0.24.0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment