Is there a way to register to memory alarm of rabbitmq

My application just got freeze because the memory usage of rabbitmq exceeded its threshold.

I am using pika and pyrabbit as a python wrappers for handling channels and connections. I wander if there is a way that my process will register to something and get a notification when that event occurs (and hopefully even a bit before it does).

1 answer

  • answered 2019-02-10 20:11 eandersson

    When using rabbitpy you can check if the blocked flag is set. This flag means that the connection is being blocked due to resource constraints (most likely due to low memory).

    with rabbitpy.Connection('amqp://guest:guest@localhost:5672/%2f') as conn:
        print(conn.blocked)
    

    e.g.

    while conn.blocked:
        time.sleep(0.1)  # wait until connection is unblocked