Skip to main content

A queue using mongo as backend storage.

Project description

mongo-mq

Simple job queue using mongodb

Usage

A queue can be instantiated with a mongo collection and a consumer identifier. The consumer identifier helps distinguish multiple queue consumers that are taking jobs from the queue:

>> from pymongo import MongoClient
>> from mongomq import MongoQueue
>> queue = MongoQueue(
...   MongoClient().test.doctest_queu,
...   consumer_id="consumer-1",
...   timeout=300,
...   max_attempts=3,
...   ttl=18000)

You can set ttl in seconds, after this time the job will be delete from database (default 5 hours)

New jobs/items can be placed in the queue by passing a dictionary:

>> queue.put({"foobar": 1})

A job priority key and integer value can be specified in the dictionary which will cause the job to be processed before lower priority items:

>> queue.put({"foobar": 0}, priority=1})

An item can be fetched out by calling the next method on a queue. This returns a Job object:

>> job = queue.next()
>> job.payload
{"foobar": 1}
>> job.status
'started'

Running Tests

Unit tests can be run with

$ python setup.py nosetests

Credits

Zaytsev Dmitriy, maintainer

Project details


Release history Release notifications

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for mongo-mq, version 0.0.1
Filename, size File type Python version Upload date Hashes
Filename, size mongo-mq-0.0.1.tar.gz (5.4 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page