title: How to stop rollback in MDB?
body: <p>I have a onMessage method where I'm reciving an ObjectMessage from the Queue and using that information to populate and persist a JPA entity object. But when something goes wrong while persisting the entity object it is re-executing the onMessage(). My guess is it is pushing the ObjectMessage back the queue and hence the onmessage is getting executed again. This way I'm entering an infinite loop. How can  stop onMessage() to get execute again or control the no of times it gets executed. Here is the code I have. 
  Error is happening at saveAuditData(auditInfo).</p>
  
  <pre><code>public void onMessage(Message inMessage) {
     log.debug("Entering onMessage() Method.");
     AuditInfo auditInfo = null;
     try {
         ObjectMessage om = (ObjectMessage) inMessage;  
         auditInfo = (AuditInfo) om.getObject();
         log.debug("Message received : " + auditInfo.getApiUsed());
         log.debug("Calling saveAuditData().");
         saveAuditData(auditInfo);
         log.debug("Leaving onMessage() Method.");
     }
     catch (Exception e) {
         e.printStackTrace();
         log.debug("Error persisting Audit Info.",e);
         log.debug("Printing Audit Info:");
         log.debug(auditInfo.toString());
     }
  
  }
  private void saveAuditData(AuditInfo auditInfo) {
      log.debug("Entering saveAuditData() Method.");
      log.debug("Populating Audit Object.");
      IdmAudit idmAudit = new IdmAudit();
      idmAudit.setApiUsed("API");
      idmAudit.setAppClientIpAddress("localhost");
      idmAudit.setAuditActivity("activity1");
      idmAudit.setAuditData(auditInfo.getAuditData());
      idmAudit.setAuditGroup(AUDIT_GROUP);
      idmAudit.setAuditType("Type");
      idmAudit.setIdmAuditCreationDate(new Date());
      idmAudit.setLocationCd("Location");
      idmAudit.setPurgeDate(null);
      idmAudit.setSubscriberId(new BigDecimal(0));
      idmAudit.setSuccessInd("Y");
      idmAudit.setUserId(new BigDecimal(0));
      idmAudit.setAuditSource("Source");
      idmAudit.setVersionNumber(new BigDecimal(0));
  
      log.debug("Saving Audit.");
      entityManager.persist(idmAudit);
      entityManager.flush();
      log.debug("Leaving saveAuditData() Method.");
  }
  </code></pre>