Handling long running tasks in pika / RabbitMQ

后端 未结 6 572
没有蜡笔的小新
没有蜡笔的小新 2020-12-04 09:26

We\'re trying to set up a basic directed queue system where a producer will generate several tasks and one or more consumers will grab a task at a time, process it, and ackn

6条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-04 09:59

    I encounter the same problem you had.
    My solution is:

    1. ture off the heartbeat on the server side
    2. evaluate the maximum time the task can possible take
    3. set the client heartbeat timeout to the time got from step2

    Why this?

    As i test with the following cases:

    case one
    1. server heartbeat turn on, 1800s
    2. client unset

    I still get error when task running for a very long time -- >1800

    case two
    1. turn off server heartbeat
    2. turn off client heartbeat

    There is no error on client side, except one problem--when the client crashes(my os restart on some faults), the tcp connection still can be seen at the Rabbitmq Management plugin. And it is confusing.

    case three
    1. turn off server heartbeat
    2. turn on client heartbeat, set it to the foresee maximum run time

    In this case, i can dynamic change every heatbeat on indivitual client. In fact, i set heartbeat on the machines crashed frequently.Moreover, i can see offline machine through the Rabbitmq Manangement plugin.

    Environment

    OS: centos x86_64
    pika: 0.9.13
    rabbitmq: 3.3.1

提交回复
热议问题