title: MessageDriverBean - Retry mechanism
body: <p>I've been reading around SO and some other google results and I got confused, some say I've to call <code>context.setRollbackOnly();</code> other say it is not required as the MDB will do it by himself.</p>
  
  <p>So, I've a <code>MessageDrivenBean</code> class that receives messages from a <code>JMS Queue</code>.</p>
  
  <pre><code>@MessageDriven(name = "MyEventReceiverJMS", activationConfig = {
      @ActivationConfigProperty(propertyName = "destinationLookup", propertyValue = "jms/TheQueue"),
      @ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Queue"),
      @ActivationConfigProperty(propertyName = "acknowledgeMode", propertyValue = "Auto-acknowledge")
  })
  public class MyEventReceiverJMS implements MessageListener {
  
      private final Logger logger = LoggerFactory.getLogger(getClass());
  
      @Resource
      private MessageDrivenContext context;
  
  
      @Override
      public void onMessage(Message message) {
  
          try {
              // Some logic goes here
          } 
          catch (JMSException ex) {
              logger.error("JMSException|could not retrieve object from the message body - reason: {}", ex.getMessage());
              context.setRollbackOnly();
          } 
          catch (JSONException ex) {
              logger.error("error while creating the JSON - reason: ", ex.getMessage());
              context.setRollbackOnly();
          } 
          catch (IOException ex) {
              logger.error("could not communicate with the server - reason: {}", ex.getMessage());
              context.setRollbackOnly();
          }
      }
  }
  </code></pre>
  
  <p>My question is, if there is an exception on the <code>onMessage</code> will the <code>message</code> (or as I call them, event) be put back on the Queue by the MDB or do I have to call <code>context.setRollbackOnly();</code> on every catch to put the message back?</p>