Skip to content

Queue Limit in RabbitMQ for non-HA

Queue Limit in RabbitMQ for non-HA in RabbitMQ Issues.

4 min read Updated SS RS

Queue Limit in RabbitMQ for non-HA#

  1. Delete the policies either in RabbitMQ UI or RabbitMQ server.

    1. Follow the below steps in RabbitMQ UI

      1. Login to RabbitMQ UI.
      2. Click on Admin Tab and at right side click on policies
      3. Select each policies and delete it one by one

        Note: The policies are deleted in order to accommodate changes, test configurations, clean up the configuration, enforce security measures, and facilitate reconfiguration. The specific reasons for policy deletion can vary depending on the evolving needs and maintenance of the RabbitMQ system.

    2. Follow the below steps in the RabbitMQ server:

      1. List all the policies in RabbitMQ.

        rabbitmqctl list_policies -p vhost001
        

        Expected Output:

        Listing policies for vhost "vhost001" ...
        vhost     name        pattern    apply-to          definition
        priority
        vhost001 policy001    queue001   queues            {"max-length":100}    0
        
      2. Execute the below curl command to delete the specific policy.

        rabbitmqctl clear_policy -p vhost001 <policy name>
        

        For Example:

        rabbitmqctl clear_policy -p vhost001 <policy001>
        

        Expected Output:

        Successful: If the above executed command is successful, then there wont be any output but the policy will be deleted. To check the same, list the policies in the virtual host.

        Unsuccessful: If the command is not executed successful, then there will be an error displayed in the output.

        Error: Policy '<policy001>' not found in virtual host 'vhost001'.
        
      3. Login to RabbitMQ container:

        podman ps | grep -i rabbitmq
        

        Expected Output:

        068f8919vfc0 support.heal:8091/rabbitmq:3.11
        2 weeks ago   Up 2 weeks
        rabbitmq-node1-56ce3ec5-8366-9b2a-b0fa-469f078b700f
        
      4. Collect the container ID and execute the below command:

        podman exec -it <container ID> bash
        

        For Example:

        podman exec -it 068f8919bfc4 bash
        

        Expected Output:

        [root@support-n1 Heal]# podman exec -it 068f8819bfc4 bash
        bash-5.1#
        
      5. Confirm if all the policies are deleted inside the container.

        rabbitmqctl list_policies
        

        Expected Output:

        Listing policies for vhost "/" .. .
        vhost    name    pattern apply-to        definition                       priority
        /        ha-policy     .      queues { "max-length-
        bytes" :10000 }    0
        
  2. Run the below curl command from RabbitMQ heal server:

    curl -X PUT -k --user guest:guest -H 'content-type:
    application/json' --data '{"pattern": ".", "apply-to": "queues",
    "definition": {"max-length": 10000} }' https://<primaryiprabbitmq>:
    <rabbitmqwebport>/api/policies/%2f/ha-policy
    

    Change the Max-length as per requirement default we will set 10000.

    Expected Output:

    Successful: There wont be any output if the command is successful.

    Unsuccessful: The below error will be obtained when the curl command is unsuccessful.

  3. Navigate to purge all the queues either in RabbitMQ UI or RabbitMQ server, as below:

    1. Purge the queues in RabbitMQ UI
      1. Click on Queues and then click on the Que Name.
      2. Click on the Purge Messages and OK.
    2. Purge all the queues in RabbitMQ server.

      1. List all the RabbitMQ queues

        rabbitmqctl list_policies
        

        Expected Output:

        Timeout: 60.0 seconds ...
        Listing queues for vhost / ...
        name    messages
        a1-event-messages                          5
        raw-forensic-messages                      2
        collation-messages                         0
        nor-thresholds 0
        agent-maintenance-response-messages                 0
        anomaly-event-signal-messages                  0
        collated-transaction-messages                  0
        violated-events 0
        anomaly-event-action-messages                  12
        static-aggregated-kpi   24
        signal-messages 4
        command-messages                           0
        

        In the above output, there are few queues with values.

      2. Purge the each que as below:

        rabbitmqctl purge_queue a1-event-messages
        

        Expected Output:

        Purging queue 'a1-event-messages' in vhost '/' ...
        
      3. Once all the queues are purged, check the status of the que’s to confirm the same:

        rabbitmqctl list_queues
        

        Expected Output:

        Timeout: 60.0 seconds ...
        Listing queues for vhost / ...
        name    messages
        a1-event-messages       0
        raw-forensic-messages                      0
        collation-messages                         0
        nor-thresholds 0
        agent-maintenance-response-messages                0
        anomaly-event-signal-messages                  0
        collated-transaction-messages                  0
        violated-events 0
        anomaly-event-action-messages                  0
        static-aggregated-kpi                      0
        signal-messages 0
        command-messages                           0
        

        Once all the queues are purged the status should be 0 in all the que’s.

"Out of Memory" (OOM) Issues With RabbitMQ#

The RabbitMQ service restarts due to OOM. The causes for this issue are as follows:

  • The high load could be attributed to inadequate memory allocation.
  • Certain queue data may not have been processed due to inactive jobs, causing the queue size to escalate.

To resolve the issue, follow the below steps:

  1. Refer to OOM Issues With Services
  2. Navigate to the below file:

    rabbitmq.nomad
    
  3. Increase the memory for Rabbit MQ in the file (according to load), as below.

    1. List the que’s present in RabbitMQ

      rabbitmqctl list_queues
      

      Expected Output:

      Timeout: 60.0 seconds ...
      Listing queues for vhost / ...
      name    messages
      a1-event-messages       5
      raw-forensic-messages   2
      collation-messages      0
      nor-thresholds 0
      agent-maintenance-response-messages              0
      anomaly-event-signal-messages   0
      collated-transaction-messages   0
      violated-events 0
      anomaly-event-action-messages   12
      static-aggregated-kpi                      24
      signal-messages 4
      command-messages                           0
      
    2. Restrict the required queue size by using the command:

      rabbitmqctl set_policy setting-queue-limit "<queue name>" '{"max-
      length":<value>}'
      

      "max-length" parameter: Specify the desired number of messages to retain within the queue, the remaining will be purged.

      For Example:

      rabbitmqctl set_policy setting-queue-limit "raw-forensic-messages"
      '{"max-length":10000}'
      
      • Successful: There wont be any output if the command is successful.
      • Unsuccessful: The error message will be obtained when the curl command is unsuccessful.