Celery Heartbeat Not Working

前端 未结 2 1734
你的背包
你的背包 2020-12-21 16:47

I have set heartbeat in Celery settings:

BROKER_HEARTBEAT = 10

I have also set this configuration value in RabbitMQ config:



        
2条回答
  •  梦毁少年i
    2020-12-21 17:36

    Celery worker support AMQP heartbeat definitely. The configuration item BROKER_HEARTBEAT is used to define the heartbeat interval of AMQP client(celery worker). We can find the description of BROKER_HEARTBEAT here Celery Doc!

    The possible causes of heartbeat not work:

    1. Use a wrong transport such as 'librabbitmq' As celery doc described, only 'pyamqp' transport support BROKER_HEARTBEAT. We need to check whether if librabbitmq package is installed or we can use 'pyamqp' transport in broker url: 'pyamqp://userid:password@hostname:port/virtual_host' rather than 'amqp://userid:password@hostname:port/virtual_host'

    2. No event send to celery worker during three heartbeat interval after boot up Check code here to see how heartbeat works! drain_events will be called during worker boot up, see code here! If there's no event sent to celery worker, connection.heartbeat_check will not be called.

    By the way, connection.heartbeat_check is defined here!

    Hopes to help someone encounter the heartbeat issue.

提交回复
热议问题