title: JMS/Glassfish - MDB Not Consuming Queue Messages
body: <p>I am using JMS for the first time and am using Glassfish 3.1.1.  I have set up a JMS Connection Factory:</p>
  
  <pre><code>Pool Name: jms/QueueConnectionFactory
  JNDI Name: jms/QueueConnectionFactory
  Resource Type: javax.jms.QueueConnectionFactory
  </code></pre>
  
  <p>and a Destination Resource:</p>
  
  <pre><code>JNDI Name: jms/ProcessBatchQueue
  Physical Destination: ProcessBatchQueue
  Resource Type: javax.jms.Queue
  </code></pre>
  
  <p>I have deployed a war with a servlet that accepts a file, parses it and saves the contents to a database.  If this is all successful it sends a message to the queue:</p>
  
  <pre><code>@Resource(lookup = "jms/ProcessBatchQueue")
  private Queue processBatchQueue;
  
  private void sendProcessBatchMessage(String batchID) throws JMSException
  {
      log.info("Attempting to send process batch message for batch ID: "
              + batchID);
  
      Connection jmsConnection = connectionFactory.createConnection();
      Session jmsSession = jmsConnection.createSession(false,
              Session.AUTO_ACKNOWLEDGE);
  
      TextMessage message = jmsSession.createTextMessage();
      message.setText(batchID);
  
      MessageProducer msgProducer = jmsSession.createProducer(processBatchQueue);
      msgProducer.send(message);
  
      jmsConnection.close();
  }
  </code></pre>
  
  <p>I have a deployed an ear with an MDB that should be listening to the queue and actioning the message:</p>
  
  <pre><code>@MessageDriven(mappedName = "jms/ProcessBatchQueue")
  public class BatchReceiver
  {
      private final Logger log = LoggerFactory.getLogger(BatchReceiver.class);
  
      public void onMessage(Message message)
      {
          log.info("Received message from jms/ProcessBatchQueue: " + message);
  
          try
          {
              if (message instanceof TextMessage)
              {
                  String batchId = ((TextMessage) message).getText();
                  // do processing
              }
              else
              {
                  log.error("Received invalid message type from jms/ProcessBatchQueue");
              }
          }
          catch (Exception ex)
          {
              String error = "Received error '" + ex.toString()
                      + "' retrieving message from jms/BatchProcessingTopic.";
  
              Throwable linkedEx = ex.getCause();
  
              if (linkedEx != null)
              {
                  log.error(error += "Linked exception: " + linkedEx.getMessage(),
                      linkedEx);
              }
              else
              {
                  log.error(error + ", " + ex.getMessage(), ex);
              }
          }
      }
  }
  </code></pre>
  
  <p>In my war logs, I get the </p>
  
  <pre><code>log.info("Attempting to send process batch message for batch ID: " + batchID);
  </code></pre>
  
  <p>statement, but in the ear logs, I get nothing that would indicate that the MDB is receiving the message.</p>
  
  <p>My understanding is that I should be able to "just" deploy the ear with the MDB and it should start receiving the messages.  Is there a config step that I've missed?</p>
  
  <p>Is there some way to confirm that the message generated in the servlet is making it to the queue in the first place?  There are no errors in any log including server.log.</p>