title: Horizontal scaling of consumers when the publisher provides sequenced messages
body: <p>In a distributed service oriented architecture, lets say I have a producer that send messages to a consumer using RMQ. </p>
  
  <p>We decided then to horizontally scale the consuming part of our architecture by adding more consumers and we faced some limitations.</p>
  
  <p>The publisher provide a sequence number in every message it sent. And it’s very important that the consumers process the messages based on the sequence number it has.</p>
  
  <p>Every time that deal with a given resource, lets say A, the publisher will send RMQ messages that says "Hey lets do sequence 1 for A" and then "Hey lets do sequence 2 for A" and so on.</p>
  
  <p>If for example the publisher provides 3 messages for A with sequences 1, 2 and 3 and the 3 messages are distributed to 3 different instances of our consumer. The message of sequence 2 is requeued until sequence 1 is well processed, same for sequence 3.</p>
  
  <p>At the end the messages are all well processed, but after many retries! This causes some latency in our system as we retries many times if we’ve 100 sequences to consume.</p>
  
  <p>A possible solution would be to make sure each set of sequences for a given resource has to be processed by the same consumer. But how can we achieve that?</p>
  
  <p>How can I avoid the requeuing in order to make sure every instance of our consumer always get the messages for a given resource well ordered?</p>