title: How does JMS Receive work internally?
body: <p>I've been researching various communication technologies/architectures/patterns/implementations (read: buzzwords) including Web Services (WCF, Axis2), ESBs, SOA, and wanted to know more about JMS with regards to messaging.</p>
  
  <p>Conceptually, JMS sounds simple.  My take is that it's an intermediate broker which manages messages from publishers and routes them to appropriate subscribers.  This is done by queueing messages as they are published, and dequeuing them as they are received.</p>
  
  <p><strong>Question 1: Is my basic understanding of JMS correct?</strong></p>
  
  <p>One of the things that bugs me when reading about technologies is when a certain level of (intentional or unintentional) hand-waving is done about a feature.</p>
  
  <p>Based on my basic understanding, a JMS Provider must be running in order to send or receive messages.  My assumption on publishing is that the JMS Provider simply waits until a message is published, then stores it in a queue (memory or database-backed, depending on implementation).  However, I am not quite sure how receive works.</p>
  
  <p><strong>Question 2: Does receive (typically) block if no messages are avaiable?</strong></p>
  
  <p><strong>Question 2b: If so, how is blocking achieved?  Does the client continuously poll for messages?  Does the server simply not respond until a message is published (how does this work without timing out?)  Does the provider initiate a call to the recipient?</strong></p>
  
  <p><strong>Question 2c: If not, how does one ensure messages are received in a timely manner, without impacting performance?</strong></p>
  
  <p>The basic description seems to lean towards a single JMS provider to ensure that messages are centrally managed not lost.  I can see scaling being an issue.</p>
  
  <p><strong>Question 3: How does JMS scale?</strong></p>
  
  <p>When scaling, I can see there being complexities to ensure that a single message is delivered to all appropriate subscribers, regardless of which physical server receives the message.</p>
  
  <p><strong>Question 3b: How does a JMS implementation ensure reliable delivery in a scaled environment?</strong></p>
  
  <p>Please note that although these questions are related to JMS, they likely apply to any messaging infrastructure.  I welcome answers specific to JMS as well as those which are more general or even specific to another technology.</p>