<commit_before><?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (c) 2007-2016 Pivotal Software, Inc.

All rights reserved. This program and the accompanying materials
are made available under the terms of the under the Apache License,
Version 2.0 (the "License”); you may not use this file except in compliance
with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->

<?xml-stylesheet type="text/xml" href="page.xsl"?>
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:doc="http://www.rabbitmq.com/namespaces/ad-hoc/doc"
      xmlns:x="http://www.rabbitmq.com/2011/extensions">
  <head>
    <title>Queue Length Limit</title>
  </head>
  <body>
    <doc:section name="max-lenth">
      <doc:subsection name="intro">
        <doc:heading>Introduction</doc:heading>
        <p>
          The maximum length of a queue can be limited to a set number of
          messages, or a set number of bytes (the total of all message
          body lengths, ignoring message properties and any overheads), or
          both.
        </p>

        <p>
          For any given queue, the maximum length (of either type) can be
          defined by clients using the queue's arguments, or in the server
          using <a href="parameters.html#policies">policies</a>. In the
          case where both policy and arguments specify a maximum length,
          the minimum of the two values is applied.
        </p>

        <p>
          Queue length settings also can be enforced by <a href="/parameters.html#operator-policies">operator policies</a>.
        </p>

        <p>
          In all cases the number of <i>ready</i> messages is used;
          unacknowledged messages do not count towards the limit. The
          fields <code>messages_ready</code> and
          <code>message_bytes_ready</code> from
          <code>rabbitmqctl list_queues</code> and the management API show the values that
          would be limited.
        </p>

        <p>
          Queue overflow behaviour can be configured using the
          <code>overflow</code> setting.
          By default messages will be dropped or dead-lettered from the front
          of the queue to make room for new messages, once the limit is reached.
          This behaviour can be changed by setting the <code>overflow</code>
          setting to <code>reject-publish</code>, then published messages will
          be discarded and publisher will be informed with
          <code>basic.nack</code> if publisher confirms are enabled.
          If a message is routed to multiple queues and rejected by at least
          one of them, the channel will NACK the message. The message will still
          be published to all other queues which can enqueue it.
        </p>
      </doc:subsection>

      <doc:subsection name="max-length-using-x-args">
        <doc:heading>Define Max Queue Length Using a Policy</doc:heading>

        <p>
          To specify a maximum length using policy, add the key
          <code>max-length</code> and / or <code>max-length-bytes</code>
          to a policy definition. For example:
        </p>

        <table>
          <tr>
            <th>rabbitmqctl</th>
            <td>
              <pre>rabbitmqctl set_policy Ten "^one-meg$" '{"max-length-bytes":1000000}' --apply-to queues</pre>
            </td>
          </tr>
          <tr>
            <th>rabbitmqctl (Windows)</th>
            <td>
              <pre>rabbitmqctl.bat set_policy Ten "^one-meg$" "{""max-length-bytes"":1000000}" --apply-to queues</pre>
            </td>
          </tr>
        </table>

        <p>
          This ensures the queue called <code>one-meg</code> can contain
          no more than 1MB of message bodies.
        </p>

        <p>
          To define an overflow behaviour - whether to drop messages from head
          or to reject new publishes, add the key <code>overflow</code> to a
          policy definition. For example:
        </p>

        <table>
          <tr>
            <th>rabbitmqctl</th>
            <td>
              <pre>rabbitmqctl set_policy Ten "^two-messages$" '{"max-length":2, "overflow":"reject-publish"}' --apply-to queues</pre>
            </td>
          </tr>
          <tr>
            <th>rabbitmqctl (Windows)</th>
            <td>
              <pre>rabbitmqctl.bat set_policy Ten "^one-meg$" "{""max-length-bytes"":2, ""overflow"":""reject-publish""}" --apply-to queues</pre>
            </td>
          </tr>
        </table>

        <p>
          This ensures the queue called <code>two-messages</code> can contain
          up to 2 messages and all additional publishes will be NACKed as long
          as it contains 2 messages.
        </p>

        <p>
          Policies can also be defined using the management plugin, see
          the <a href="parameters.html#policies">policy
          documentation</a> for more details.
        </p>
      </doc:subsection>

      <doc:subsection name="max-length-using-x-args">
        <doc:heading>Define Max Queue Length Using x-arguments During Declaration</doc:heading>

        <p>
          Maximum number of messages can be set by supplying the<commit_msg>Wording suggestions from PR review<commit_after><?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (c) 2007-2016 Pivotal Software, Inc.

All rights reserved. This program and the accompanying materials
are made available under the terms of the under the Apache License,
Version 2.0 (the "License”); you may not use this file except in compliance
with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->

<?xml-stylesheet type="text/xml" href="page.xsl"?>
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:doc="http://www.rabbitmq.com/namespaces/ad-hoc/doc"
      xmlns:x="http://www.rabbitmq.com/2011/extensions">
  <head>
    <title>Queue Length Limit</title>
  </head>
  <body>
    <doc:section name="max-lenth">
      <doc:subsection name="intro">
        <doc:heading>Introduction</doc:heading>
        <p>
          The maximum length of a queue can be limited to a set number of
          messages, or a set number of bytes (the total of all message
          body lengths, ignoring message properties and any overheads), or
          both.
        </p>

        <p>
          For any given queue, the maximum length (of either type) can be
          defined by clients using the queue's arguments, or in the server
          using <a href="parameters.html#policies">policies</a>. In the
          case where both policy and arguments specify a maximum length,
          the minimum of the two values is applied.
        </p>

        <p>
          Queue length settings also can be enforced by <a href="/parameters.html#operator-policies">operator policies</a>.
        </p>

        <p>
          In all cases the number of <i>ready</i> messages is used;
          unacknowledged messages do not count towards the limit. The
          fields <code>messages_ready</code> and
          <code>message_bytes_ready</code> from
          <code>rabbitmqctl list_queues</code> and the management API show the values that
          would be limited.
        </p>
      </doc:subsection>

      <doc:subsection name="default-behaviour">
        <doc:heading>Default Max Queue Length Behaviour</doc:heading>
          <p>
            The default behaviour for RabbitMQ when a maximum queue length or
            size is set and the maximum is reached is to <em>drop</em> or
            <em><a href="dlx.html">dead-letter</a></em> messages from the front
            of the queue (i.e. the oldest messages in the queue). To modify
            this behaviour, use the <code>overflow</code> setting described
            below.
          </p>
      </doc:subsection>

      <doc:subsection name="overflow-behaviour">
        <doc:heading>Queue Overflow Behaviour</doc:heading>
        <p>
          Use the <code>overflow</code> setting to configure queue overflow
          behaviour. If <code>overflow</code> is set to <code>reject-publish</code>,
          the most recently published messages will be discarded. In addition, if
          <a href="confirms.html#publisher-confirms">publisher confirms</a>
          are enabled, the publisher will be informed of the reject via a
          <code>basic.nack</code> message. If a message is routed to multiple
          queues and rejected by at least one of them, the channel will inform
          the publisher via <code>basic.nack</code>. The message will still be
          published to all other queues which can enqueue it.
        </p>
      </doc:subsection>

      <doc:subsection name="max-length-using-x-args">
        <doc:heading>Define Max Queue Length Using a Policy</doc:heading>

        <p>
          To specify a maximum length using policy, add the key
          <code>max-length</code> and / or <code>max-length-bytes</code>
          to a policy definition. For example:
        </p>

        <table>
          <tr>
            <th>rabbitmqctl</th>
            <td>
              <pre>rabbitmqctl set_policy my-pol "^one-meg$" '{"max-length-bytes":1048576}' --apply-to queues</pre>
            </td>
          </tr>
          <tr>
            <th>rabbitmqctl (Windows)</th>
            <td>
              <pre>rabbitmqctl.bat set_policy my-pol "^one-meg$" "{""max-length-bytes"":1048576}" --apply-to queues</pre>
            </td>
          </tr>
        </table>

        <p>
          The <code>my-pol</code> policy ensures that the <code>one-meg</code>
          queue contains no more than 1MiB of message data. When the 1MiB limit
          is reached, the oldest messages are discarded from the head of the
          queue.
        </p>

        <p>
          To define an overflow behaviour - whether to drop messages from head
          or to reject new publishes, add the key <code>overflow</code> to a
          policy definition. For example:
        </p>

        <table>
          <tr>
            <th>rabbitmqctl</th>
            <td>
              <pre>rabbitmqctl set_policy my-pol "^two-messages$" '{"max-length":2,"overflow":"reject-publish"}' --apply-to queues</pre>
            </td>
          </tr>
          <tr>
            <th>rabbitmqctl (Windows)</th>
            <td>
              <pre>rabbitmqctl.bat set_policy my-pol "^two-messages$" "{""max-length"":2,""overflow"":""reject-publish""}" --apply-to queues</pre>
            </td>
          </tr>
        </table>

        <p>
          The <code>my-pol</code> policy ensures that the <code>two-messages</code>
          queue contains no more than 2 messages and all additional publishes
          are sent <code>basic.nack</code> responses as long as the queue
          contains 2 messages and publisher confirms are enabled.
        </p>

        <p>
          Policies can also be defined using the management plugin, see
          the <a href="parameters.html#policies">policy
          documentation</a> for more details.
        </p>
      </doc:subsection>

      <doc:subsection name="max-length-using-x-args">
        <doc:heading>Define Max Queue Length Using x-arguments During Declaration</doc:heading>

        <p>
          Maximum number of messages can be set by supplying the
{'fraction_non_alphanumeric': 0.10289794204115918, 'fraction_numerical': 0.0073078538429231414, 'mean_word_length': 2.2134952766531715, 'pattern_counts': {'":': 12, '<': 251, '<?xml version=': 2, '>': 251, 'https://': 0, 'lorem ipsum': 0, 'www.': 8, 'xml': 12}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3579909', 'n_tokens_mistral': 3374, 'n_tokens_neox': 3215, 'n_words': 1201}