title: Processing a message exactly once
body: <p>Please consider the scenario as shown in the attached image :</p>
  
  <p><img src="https://i.stack.imgur.com/evTQB.jpg" alt="Multiple instances of multiple apps."></p>
  
  <ol>
  <li>The Portal(producer) will send some message to the bus to which has to be processed by multiple applications(consumer) – PAYROLLAPP, HELPDESK etc.</li>
  <li>Multiple instances of consumer applications may be running, also these <strong>instances can be added/
  removed dynamically</strong></li>
  <li>Now, it is critical to ensure that <strong>message is processed only once, per application</strong> i.e if
  PAYROLLAPP -1 processes the message, PAYROLLAPP -2 should NOT process it; of course, in the
  above diagram, HELPDESK – 1 must process it. In short, in case of multiple instances, exactly one
  must process the message, once</li>
  <li>When I searched for answers, most of the stuff was about creating a 'selective consumer' - a consumer that accepts/rejects a message based on some logic - please note that no changes/additions/wrapping can be done for the applications shown in the diagram; the logic has to reside somewhere in the provider that manages the bus</li>
  </ol>
  
  <p>Please guide about the same.</p>
  
  <p>Adding more details after Petter's answer :</p>
  
  <p><img src="https://i.stack.imgur.com/LQ6Cf.jpg" alt="My current understanding and approaches"></p>
  
  <ol>
  <li>The items to the to the left of the left-dotted line are the 'approaches' - Pure JMS,ESB,EAI</li>
  <li>The items to the to the right of the right-dotted line are the 'implementations'</li>
  </ol>
  
  <p><strong>Now, the big part - QUERIES :</strong></p>
  
  <ol>
  <li>Irrespective of the solution(pure JMS, ESB, EAI), does the part
  below the horizontal dotted line(application-specific queues) needs
  to be implemented?</li>
  <li>How does the usage of ESB(JBoss ESB etc.), instead of ‘pure’ JMS(Active MQ etc.), help/
  hamper? Does ESB provide any advantage over JMS which is ‘java-only’(?). I am hell confused
  – ‘ESB or JMS’, even after referring threads like these : <a href="https://stackoverflow.com/questions/5322675/jms-and-esb-how-they-are-related">JMS and ESB - how they are related?</a>.
  It has one reply which says “JMS is not well suited
  for the integration of REST services, File systems, S/FTP, Email, Hessian, SOAP etc. which are
  better handled with an ESB that supports these types natively. For example, if you have a process
  that dumps a CSV file of 500MB at midnight, and you want another system to pickup the file,
  parse CSV and import into a database, this can easily be accomplished by an ESB - whereas a
  solution with just JMS will be bad. Similarly, integration of REST services, with load balancing/
  failover to multiple backend instances can be done better with an ESB supporting HTTP/S
  natively.” <em>It only added to my confusion !!!</em></li>
  <li>Is the usage of EAI framework (Apache Camel etc.) an approach entirely different from the pure
  JMS or ESB approach? If yes, how and what are the pros/cons?</li>
  <li>I was told that ESB alone won’t help, BPM(or something else?) needs to be used to define and
  store the ‘routing’ logic – is this true?</li>
  </ol>