title: EJB 3.x onMessage() vs @Timeout transactional context
body: <p>in EJB 3.x for both the <code>onMessage()</code> method of MDBs and the <code>@Timeout</code> method of SLSBs and MDBs there is no transaction propagation. That is, there is no client for the execution of the method, so a transaction can't be possibly propagated.</p>
  
  <p>When using Container-managed transactions, I would expect the two cases to accept the same <code>javax.ejb.TransactionAttributeType</code>. However, they don't.</p>
  
  <p>For the <code>onMessage()</code> method, REQUIRED and NOT_SUPPORTED are the acceptable transaction attributes, whereas for <code>@Timeout</code> methods REQUIRED, REQUIRES_NEW and NOT_SUPPORTED.</p>
  
  <p>In particular, for the <code>@Timeout</code> methods the spec says (par. 18.2.8):</p>
  
  <blockquote>
    <p>Note that the container must start a
    new transaction if the REQUIRED
    (Required) transaction attribute is
    used. This transaction attribute value
    is allowed so that specification of a
    transaction attribute for the timeout
    callback method can be defaulted.</p>
  </blockquote>
  
  <p>If I get this correctly, normally REQUIRES_NEW should be used here, but because REQUIRED is the default for an EJB, it is also allowed for <code>@Timeout</code> methods, giving it the same semantic as REQUIRES_NEW, since there is no possibility of a transaction to be propagated.</p>
  
  <p>Questions:</p>
  
  <ol>
  <li>Is my understanding correct?</li>
  <li>Why isn't REQUIRES_NEW acceptable also in <code>onMessage()</code>? Is it different somehow in respect of transactions?</li>
  </ol>
  
  <p><strong>UPDATE:</strong>
  The same goes for other cases where REQUIRES_NEW is supported: @Asynchronous and @PostConstruct/@PreDestroy methods.</p>