[Fixed]-SQS with Celery configuration

5👍

This is actually a good behavior so you can monitor which instances (IPs or local names) are accessing your SQS account. It is just one request, so it won’t cost you anything.

4👍

You need to set these:

 CELERY_ENABLE_REMOTE_CONTROL = False 
 CELERY_SEND_EVENTS = False

To disable that.

1👍

If you want to connect the Celery with SQS so you should create an celery app using the below code

from celery import Celery
def make_celery(app):
    celery = Celery(
        app.import_name,
        broker="sqs://",
        broker_transport_options={
            "queue_name_prefix": "{SERVICE_ENV}-{SERVICE_NAME}-"
        },
    )
    task_base = celery.Task

    class ContextTask(task_base):
        abstract = True

        def __call__(self, *args, **kwargs):
            with app.app_context():
                return task_base.__call__(self, *args, **kwargs)

    celery.Task = ContextTask

    return celery

Using this code you will be able to connect the Celery with SQS.

Leave a comment