How to execute celery task when new message arrives to queue?

I have a node app that puts messages in a queue using RabbitMQ. Then i have some workers in python using celery. I want celery to automatically execute some task when a new message is posted to that queue. How can i achieve this? Any help is appreciated.

Try this: In node your message should have this format

var message = {
             "id": "4cc7438e-afd4-4f8f-a2f3-f46567e7ca77",
             "task": "task_name",
             "args": ["this is my arg"],
             "kwargs": {},
             "retries": 0
            }

And in Celery your task should be defined like this:

@app.task(serializer='json', name='task_name')
def task1(arg1):
    print arg1

Also don't forget to configure routes in your celery config file, for example:

app.conf.update(
  CELERY_TASK_RESULT_EXPIRES=3600,
  CELERY_ROUTES = {'tasks.task1': {'queue': 'queue_name'}},
  CELERY_ACCEPT_CONTENT = ['application/json']
)