[Answered ]-How to run django celery with SQS?

2👍

If you are using Celery 4.0.0 and have this line

app.config_from_object('django.conf:settings', namespace='CELERY')

Namespace tells that all Celery related settings should start with CELERY

Use then CELERY_BROKER_URL, CELERY_BROKER_TRANSPORT_OPTIONS.

0👍

I’ve just managed to link up Celery and SQS.

In my settings:

BROKER_URL = 'sqs://'
BROKER_TRANSPORT_OPTIONS = {'region': 'eu-west-1',
                            'visibility_timeout': 43200,# in seconds
                            'polling_interval': 3,
                            'queue_name_prefix':'repricer-stage-',
                            'CELERY_SEND_TASK_ERROR_EMAILS': True
                            }

Above, note BROKER_RUL = ‘sqs://’:

The login credentials can also be set using the environment variables
AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY, in that case the broker
url may only be sqs://.

source.

Be aware that you need a worker active to interact with SQS. Via the console (in your virtual environment):

$ celery -A proj worker -l info

source

👤andyw

Leave a comment