<p>I'm trying to solve a problem where the main reason is that I need to split a big message, into small messages before sending it to RabbitMQ (can't change that).</p>
<p>But doing this, creates another problem:
The consumer of this message is in a Kubernetes deployment with 2 replicas of the pod. But the messages created in the split CANT'T be processed in both of them (it would create a huge problem).</p>
<p>So, the question is: how can I make sure that only one of the pods will be consuming the messages??</p>
<p>My first idea was to create a queue only for this case, and put an env variable with it's routing key in only one of the pods. But seems like it is kinda anti-pattern, so I'm trying to avoid this approach.</p>

Lucas Mendes Sales
<p>Not a direct answer to you question, but I recommend you should think about your solution.</p>
<p>For <a href="https://stackoverflow.com/questions/44927937/large-rabbitmq-message-in-slow-network/47544515#47544515">performance and availability reasons</a> we restricted the maximum message size to 256 KB per message in our message queuing infrastructure. For larger messages, the user data is transmitted out-of-band and only a message with download information is sent that the payload is available for download somewhere else. We decided to use MinIO which is S3-compatible as storage for out-of-band storage of user data. The workflow can be described in pseudo code the following.</p>
<p>Producer</p>
<pre><code>if data &gt; 255kb
  s3handle = s3connect(username, password, connection_url)
  s3handle.s3upload(bucketname, filename, data)
  download_url = s3handle.s3getObjectUrl(bucketname, filename, duration)
  message.send(queue, download_url)
else
  message.send(queue, data)
</code></pre>
<p>Consumer</p>
<pre><code>data = message.read(queue)
if (data of type url)
  contents = getUrl(data)
else
  contents = data
</code></pre>
<p>We've been using this for many years with no problems.</p>
