Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I see a few (actually 2) mix ups there:</p> <p>i - you are using an XA Session but you are not declaring any transaction boundaries... which is usually done on Session Beans and MDBs. I'm not sure you can do that on this Stateless.</p> <p>if you don't use any declarative Transaction, you would have to enlist the XID manually.</p> <p>ii - the jmsXA is the default Resource Adapter connection factory. It has a pool on it already. So whenever you create a new session you are taking out of the pool. When you close it you are returning it to the pool.</p> <p>You could use a regular Connection Factory. Just in the InVMConnectionFactory (or whatever you have defined on your standalone, outside of the PooledConnectionFactories assuming you are on JBoss... and then just use regular JMS.</p> <p>Even the regular Connection Factory can be used with XA but on that case you will need to make sure you enlist it using the Transaction Manager's api directly.</p> <p>if you use your regular connection factory, you can then just keep it connected as long as you want.</p> <p>Please let me know how it goes and I will help you. I know you started a bounty.. but I would have answered it for free :)</p> <p>I couldn't find any example on the EJB Tutorial about using Transactions with a Singleton.</p> <p>I would recommend you using it through a Statless or Stateful Session Bean and then applying the @TransactionAttribute to the Bean.</p> <p>The Java EE 6 Tutorial has some good information about it:</p> <p><a href="http://docs.oracle.com/javaee/6/tutorial/doc/bncij.html" rel="nofollow">http://docs.oracle.com/javaee/6/tutorial/doc/bncij.html</a></p> <p>notice that a message won't be available until you commit. So if you send a message within a transaction you won't be able to receive it on the same transaction.</p> <p>On your edit1 example you are sending a message and consuming it on the same transaction. That won't work as you first need to commit the producing method before you can consume it. You would need two transactions on this case, so Edit1 is broken.</p> <p>Also: make sure you close the Connection at the end. Since you are using JmsXA (or a pooled connection factory) you will have the polling done automatically by the Application Server.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload