Package: django-rq-mail
django-rq-mail is a simple Python library based onrqto store emails sent
byDjangoand process them in the background with workers.As django-rq-mail is based onrq, it’s entirely backed byRedis.Architecturedjango-rq-mail adds new elements to enjoySorted SetsfromRedis.For the purpose of django-rq-mail, it implements the concept ofWaitingQueuewhich delays the processing of a job with a timestamp.The default behavior ofrqis to process jobs viaBLPOPwhich
blocks the connection when there are no elements to pop from any of the given queues.
With this behavior there is no way to delays the processing of a job and when it’s failingrqpushs it in a failed queue.
Of course, you can requeue this job later but there is no fallback mechanism.In django-rq-mail you can define fallback steps (in seconds) to retry a job until
it’s not failing. When a job has been tested on each steps we reintroduce
the default behavior ofrqon pushing it in the failed queue.Each steps will create a waiting queue and when a job is failing we take the
current timestamp with the delta to retry it in the future.This mechanism is possible withZADDwhich
adds a serialized job in the queue with a score andZREVRANGEBYSCOREto return all the elements in the sorted set with a score between max (current timestamp) and min.As you may understood, we have dropped the default blocking behavior
to replace it by a daemon which is running each seconds.InstallationEither check out the package fromGitHubor it pull from a release via PyPIpip install django-rq-mailAdd ‘rq_mail’ to yourINSTALLED_APPSINSTALLED_APPS = (
    'rq_mail',
)to use therq_mailcommand (via Django commandline) shipped by django-rq-mail.This command is a minimal integration ofrqintoDjangoto launch theDispatcher.DefineEMAIL_BACKENDEMAIL_BACKEND = 'rq_mail.backends.RqBackend'DefineRQ_MAIL_EMAIL_BACKENDthe backend used to send your emails, for exampleRQ_MAIL_EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'LoggingRQ 0.3.3 uses standard Python’slogging, this means
you can easily configurerqworker’s logging mechanism in django’ssettings.py. For example:LOGGING={'version':1,'disable_existing_loggers':False,'formatters':{'rq_console':{'format':'%(asctime)s%(message)s','datefmt':'%H:%M:%S',},},'handlers':{'rq_console':{'level':'DEBUG','class':'rq.utils.ColorizingStreamHandler','formatter':'rq_console','exclude':['%(asctime)s'],},},'loggers':{'rq.worker':{'handlers':['rq_console'],'level':'DEBUG'},}}UtilisationOnce you have installed it, you can runpython manage.py rq_mailfrom your shell.ConfigurationRQ_MAIL_PREFIXThe prefix used to name all queues created by django-rq-mail.RQ_MAIL_MAIN_QUEUEThe name of the main queue.RQ_MAIL_EMAIL_BACKENDThe email backend used to send emails when they are processed in the background.RQ_MAIL_REDIS_HOSTThe Redis host used to connect.RQ_MAIL_REDIS_PORTThe Redis port used to connect.RQ_MAIL_REDIS_DBThe Redis database used to connect.RQ_MAIL_REDIS_PASSWORDThe Redis password used to connect.RQ_MAIL_REDIS_URLThe Redis url used to connect.RQ_MAIL_REDIS_SOCKETThe Redis socket used to connect.RQ_MAIL_FALLBACK_STEPSA simple list of timing to create waiting queues.You can define as much steps as you want, each will be transformed to a queue.
So if you define 10 steps, you will allow a message to fail 10 times until it
will go in the failed queue.