title: RabbitMQ exchange queue max length
body: <p>I am trying to apply some flow control in my application which based on RabbitMQ.</p>
  
  <p>A very narrow brief over my system:</p>
  
  <ul>
  <li>There are some blue-workers that scan and input directory and publish messages to an exchange.</li>
  <li>There are other red-workers that consume from this exchange (based on routing keys) and do whatever they do with the data and than delete it.</li>
  </ul>
  
  <p>The data that is "stored" in the exchange is quite big and the time that takes to a worker to go over it is noticeable. After some time I am getting a memory warning from RabbitMQ which states that the memory usage is too high and all publishing operations are stopped.</p>
  
  <p>I tried to increase the amount of memory Rabbitmq is using but it just postpone the problem in a few hours (of runtime). I also made the queues disk-based instead of ram-based but my disk got full instead.</p>
  
  <p>Since my input is not that big I can live with a "large" input queue from which the blue-workers read their input. So I thought to try and set some "max length" on the link between the blue-workers and the exchange. I believe that I won't loose anything here since the real bottleneck of my system is the red-workers  (by the way I declared the link between the red-workers and the exchange with a <code>prefech_count=2</code>).</p>
  
  <p>After saying all that... I didn't manage to apply such a max-length :(
  I am using <code>Pika</code> to declare my queues and working with channels.
  I read this (<a href="https://www.rabbitmq.com/maxlength.html" rel="nofollow noreferrer">https://www.rabbitmq.com/maxlength.html</a>) but didn't manage to implement it in my code and I would like to see an example that uses this max-size flag.</p>