protected String consume() throws Exception {
    Connection con = null;
    MessageConsumer c = consumer;
    if (connectionPerMessage) {
      con = factory.createConnection();
      con.start();
      Session s = con.createSession(false, Session.AUTO_ACKNOWLEDGE);
      c = s.createConsumer(getConsumeDestination());
    }
    TextMessage result = (TextMessage) c.receive(timeout);
    if (result != null) {
      if (audit.isDuplicate(result.getJMSMessageID())) {
        throw new JMSException("Received duplicate " + result.getText());
      }
      if (!audit.isInOrder(result.getJMSMessageID())) {
        throw new JMSException("Out of order " + result.getText());
      }

      if (connectionPerMessage) {
        Thread.sleep(SLEEP_TIME); // give the broker a chance
        con.close();
      }
    }
    return result != null ? result.getText() : null;
  }
 public boolean isSendToDeadLetterQueue(Message message) {
   boolean result = false;
   if (message != null) {
     result = true;
     if (enableAudit && messageAudit.isDuplicate(message)) {
       result = false;
       if (LOG.isDebugEnabled()) {
         LOG.debug(
             "Not adding duplicate to DLQ: "
                 + message.getMessageId()
                 + ", dest: "
                 + message.getDestination());
       }
     }
     if (!message.isPersistent() && !processNonPersistent) {
       result = false;
     }
     if (message.isExpired() && !processExpired) {
       result = false;
     }
   }
   return result;
 }