Rabbitmq one queue multiple consumers
<p>I've multiple consumers which are polling on the same queue, and checking the queue every X seconds, basically after X seconds it could be that at least two consumers can launch <code>basic.get</code> at the very same time.  </p>

<p>Question are:<br>
1.If at least two consumers at the same time can get the same message?</p>

<p>2.According to what I understood only <code>basic_ack</code> will delete a mesage from the queue, so suppose we have the following scenario:  </p>

<p><code>Consumer1</code> takes msg with basic.get and before it reaches <code>basic_ack</code> line , <code>Consumer2</code> is getting this message also (<code>basic.get</code>), now <code>Consumer1</code> reaches the <code>basic.ack</code>, and only now <code>Consumer2</code> reaches its own <code>basic.ack</code>.<br>
 What will happen When Consumer2 will reach its <code>basic.ack</code>?<br>
Will the message be processes by Consumer2 as well, because actions are not atomic?</p>

<p>My code logic of consumer using python pika is as follows:</p>

<p><code>while true:
     m_frame =None
     while(m_frame is None):<br>
        self.connection.sleep(10)
        m_frame,h_frame,body = self.channel.basic_get('test_queue')
     self.channel.basic_ack(m_frame.delivery_tag)
     [Doing some long logic - couple of minutes]
</code>  </p>

<p><strong>Please note that I don't use basic.consume</strong>  </p>

<p>So I don't know if round robin fetching is included for such usage</p>

<blockquote>
  <p>1.If at least two consumers at the same time can get the same message?</p>
</blockquote>

<p>no - a single message will only be delivered to a single consumer.</p>

<p>Because of that, your scenario #2 doesn't come into play at all. </p>

<p>You'll never have 2 consumers working on the same message, unless you <code>nack</code> the message back to the queue but continue processing it anyways.</p>

python python-2.7 rabbitmq pika