title: How do I do a transacted receive in a Message Driven Bean in Java EE 6?
body: <p><em>Sending</em> a transacted message from an MDB or other code is documented all over the web. </p>
  
  <p>But how do you do a transacted <em>receive</em> with an MDB? The documentation that I've come across suggests that, much like a transacted send, you'll need to call <code>Session.commit()</code> to confirm reception of the message. </p>
  
  <p>However, I can't figure out how to access the (JMS) session instance! It doesn't seem to be available via the <code>MessageDrivenContext</code> instance. </p>
  
  <p>Also, I need to use BMT (bean managed transactions) in my MDB in order to control race-conditions involving the <code>afterCompletion</code> method of a <code>javax.transaction.Synchronization</code> instance. Being able to do a transacted receive would be nicer than throwing a (runtime) exception from <code>onMessage(Message)</code>.</p>