This a wrapper that standardizes queue services for:
Sometimes there is a need to utilize multiple queue services, but refactoring code is not an option. With pyqueue_wrapper, one can easily switch between the supported queue services with a configuration file.
pip install https://bitbucket.org/imedicare/pyqueue_wrapper/get/master.zip{"BASENAME": "my_queue","ENV_MODE": "dev","TYPE": "ironio","ironio": {"TOKEN": "xxxxxxxxx","PROJECT_ID": "yyyyyyyyyy","MSG_EXPIRES": 1800,// seconds"MSG_TIMEOUT": 8400// seconds},"sqs": {"TYPE": "sqs","AWS": {"AWS_ACCESS_KEY": "zzzzzz","AWS_SECRET_KEY": "xxxxxx"}}}The name of the queue depends on two configuration variables:
- BASENAME - name of queue
- ENV_MODE - environment suffix used on naming of queue
In this example, the full name of the queue would become my_queue_dev
Be sure to specify the TYPE:
TYPE - the queue service to use (eg: 'sqs' for AWS SQS, 'ironio' for iron.io QS)
importjsonimportpyqueue_wrapper### load configuration fileconfig=json.loads(open('/path/to/config_file.json')) # see configuration example aboveq=pyqueue_wrapper.Queue(config)
### methodsnew_message= ({'msg1':'this is a test'})
q.put(new_message)
## get# iterate through queueformsginq:
print(msg) #Note: will contain 'qid' as reference extra field# get a single messagereceived_message=q.get()
## deleteqid=received_message['qid']
q.delete(qid) # Note: not required for AWS SQS, because auto deletes## clearq.clear() # clear all messages in queue