newbie question to RabbitMQ and Celery
I started playing around with Celery and RabbitMQ this morning and defined some basic tasks to see how the performance will improve on my server.
I have added my rabbitmq user, vhosts and set my permissions. Started my RabbitMQ server
In a very detailed tutorial I found these 开发者_运维技巧guys use celerybeat and celeryd to see the status of some task, and also to execute them.
the detailed tutorial by Rich Leland
Do you also need celery somehow, or are the steps I have taken enough?
Nowhere did I see any info or notes about this... just asking
Well, you'll need to have some sort of celery process running in order to handle tasks in the queue. The celeryd process listens on the queue, and executes tasks according to your settings. If you don't have a celeryd process running, you'll just be adding tasks to the queue, but never emptying it.
If you're just interested in seeing your queues, I'd recommend installing the RabbitMQ management plugin.
http://ask.github.com/celery/getting-started/introduction.html
- Start your RabbitMQ server
- Define your celeryconfig.py
- Start your celery daemon: celeryd
RabbitMQ has a guest login, so that's a faster way to get started. Put this in celeryconfig.py:
import sys
sys.path.append('.')
BROKER_HOST = "localhost"
BROKER_PORT = 5672
BROKER_USER = "guest"
BROKER_PASSWORD = "guest"
BROKER_VHOST = "/"
CELERY_RESULT_BACKEND = "amqp"
CELERY_IMPORTS = ("tasks",)
For a quick test, put this in tasks.py:
from celery.task import task
@task
def add(x, y):
return x + y
if __name__ == "__main__":
result = add.delay(4, 4)
result.wait()
Start celeryd in the same directory has celeryconfig.py and tasks.py:
celeryd --loglevel=INFO
Finally, run tasks.py
精彩评论