您可以设置的RabbitMQ
x-max-length
使用队列预先声明海带
例如:
import timefrom celery import Celeryfrom kombu import Queue, Exchangeclass Config(object): BROKER_URL = "amqp://guest@localhost//" CELERY_QUEUES = ( Queue( 'important', exchange=Exchange('important'), routing_key="important", queue_arguments={'x-max-length': 10} ), )app = Celery('tasks')app.config_from_object(Config)@app.task(queue='important')def process_data(x): pass或使用政策
rabbitmqctl set_policy Ten "^one-meg$" '{"max-length-bytes":1000000}' --apply-to queues


