title: JMS Session and JPA transaction with XA
body: <p>I'm using WebSphere 8.5 with EJB 3.1 and JMS Generic provider.</p>
  
  <p>I need to write messages in a queue using a stateless session bean as a producer. The EJB is annotated with the <code>TransactionAttributeType.REQUIRED</code> because I need to perform some "DB insert" before I send messages on a queue and consume these messages reading records wrote by the producer.</p>
  
  <p>The problem is if I define a JDBC non XA datasource, the producer writes the messages in queue but the server complains about a failed 2 phase-commit of a local resource (the Datasource itself I think) and doesn't call the <code>onMessage</code> method of the MDB. If I define a JDBC XA everything works. </p>
  
  <p>My questions:</p>
  
  <ul>
  <li>Is JMS session required to be a default XA resources? And why?</li>
  <li>What happen if I configure my JMS connection factory to create a non XA JMS session in a JTA Transaction? Is that a bad practice?</li>
  <li>What happen if the consumer starts to consume message while the producer is still finishing his operations on database? Would the consumer see changes on database because they are in the same transaction?</li>
  </ul>
  
  <p>Thanks in advance, regards</p>