title: Whats the best way to process an asynchronous queue continuously in Java?
body: <p>I'm having a hard time figuring out how to architect the final piece of my system. Currently I'm running a Tomcat server that has a servlet that responds to client requests. Each request in turn adds a processing message to an asynchronous queue (I'll probably be using JMS via Spring or more likely Amazon SQS).</p>
  
  <p>The sequence of events is this:</p>
  
  <p>Sending side:<br>
  1. Take a client request <br>
  2. Add some data into a DB related to this request with a unique ID <br>
  3. Add a message object representing this request to the message queue <br></p>
  
  <p>Receiving side: <br>
  1. Pull a new message object from the queue <br>
  2. Unwrap the object and grab some information from a web site based on information contained in the msg object. <br>
  3. Send an email alert <br>
  4. update my DB row (same unique ID) with the information that operation was completed for this request. <br></p>
  
  <p>I'm having a hard figuring out how to properly deal with the receiving side. On one hand I can probably create a simple java program that I kick off from the command line that picks each item in the queue and processes it. Is that safe? Does it make more sense to have that program running as another thread inside the Tomcat container? I will not want to do this serially, meaning the receiving end should be able to process several objects at a time -- using multiple threads. I want this to be always running, 24 hours a day.</p>
  
  <p>What are some options for building the receiving side?</p>