Announcement Announcement Module
No announcement yet.
Standalone JTA (Bitronix) + JPA (XA) JDBC + JPA JMS MDP (XA) ActiveMQ Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • #16
    thanks a lot for you effort, simbo1905

    we're now evaluating transaction managers (currently bitronix and atomikos) for a standalone app that will require JPA+JMS transactions.

    this thread has helped us a lot to solve some doubts we had integrating bitronix with spring. It's also quite good to know you had support from bitronix guys.

    thanks again.


    • #17
      Working config with Atomikos


      Sorry for the delay, I had this ready in my workspace for a while but did't get to post it until now.

      Attached is the zip file with a working Atomikos config.

      Note: maven runs tests in parallel by default which causes setUp problems (Atomikos does check against parallel startups so the maven parallel setup default will not work). Use "mvn -DforkMode=once test" instead to run the tests.

      Re the application certification: if you tell me what you want to do then I can tell you if that is what I see in the logs.

      Happy 2010



      • #18
        this is great.
        now we have a full evaluation set of the most popular standalone TM's for our JTA tests. thank you all.

        just one more question about atomikos, if it's not asking too much.
        we're probably going to have to migrate from Hibernate JPA to Eclipselink.

        in order to make eclipselink JTA aware, it's needed to set the property target-server and provide a custom JTATransactionController
        class that returns a javax.transaction.TransactionManager when the method acquireTransactionManager() is called.

        could we just return a "new UserTransactionManager()" , just as it's done in the class com.atomikos.icatch.jta.hibernateTransactionManage rLookup for hibernate ?

        again thanks to both of you for your great help.
        it's really appreciated.


        • #19
          Should be ok


          Constructing a new UserTransactionManager should be OK - at least at first sight. In 99% of all cases this works fine, as a rule of thumb.



          • #20
            well , thanks to your help we've been able to make EclipseLink JPA work with Atomikos and Spring, making it full JTA aware.
            right now I cannot post the full source code, because we've been using it to test and try lots of things, and it would be quite embarrasing

            These are the steps :

            1. Add these two properties to the EclipseLink factory Bean:
            <property name="jpaProperties">
               <prop key="">my.spring.jtatest.AtomikosTransactionSessionCustomizer</prop>
               <prop key="jdbc.exclusive-connection.mode">Transactional</prop>
            target-server is the name of the class that will return an Atomikos UserTransaction when EclipseLink calls its method "acquireTransactionManager".

            2. TransactionSessionCustomizer class
            package my.spring.jtatest;
            public class AtomikosTransactionSessionCustomizer extends JTATransactionController {
              protected TransactionManager acquireTransactionManager() throws Exception {
            	        Class<?> clazz = Class.forName("com.atomikos.icatch.jta.UserTransactionManager");
            	        return (TransactionManager) clazz.newInstance();
            3. Modify persistence.xml transaction-type to "JTA"
            <persistence xmlns="" version="1.0">
              <persistence-unit name="SpringJpaTest" transaction-type="JTA">
            We had to add a dummy jta-data-source. Eclipselink complains if transaction-type is set to "JTA" and no jta-data-source is defined.
            It seems that the name doesn't matter. Our datasource is not named jdbc/MyDB2DB and it still works.

            Now we're trying to configure it with Bitronix. If we're sucessful i will post the results.

            again, thanks simon1905 and GuyPardon.
            without your help we couldn't have done it.
            Last edited by nestochi; Jan 14th, 2010, 11:06 AM.


            • #21
              Could someone explain me why the following test cannot be successfully performed?

              Basically I'm trying to embed the whole process within a global transaction but it seems that JMS queue doesn't like this at all and TextCallback.onText(String text) is never invoked.

              I'm very new to JPA-JMS so, please, forgive me if I'm missing some obvious points.

              Test code:

              	public void testJmsRecieveWithDatabaseUpdate() throws Exception {
              		TransactionTemplate transactionTemplate = (TransactionTemplate) applicationContext
              		transactionTemplate.execute(new TransactionCallbackWithoutResult() {
              			public void doInTransactionWithoutResult(TransactionStatus status) {
              				int sequence = messageSequenceDAO.readSequence("app1", "keyA");
              				assertEquals(1, sequence);
              				// set things up to scoop the text out of our MDP and perform
              				// a database opperation.
              				class Handle {
              					Object	object;
              				final Handle handle = new Handle();
              				textMessageDelegate.setTextCallback(new TextCallback() {
              					public void onText(String text) {
              						synchronized (handle) {
              							if (text.equals("without rollback")) {
              								handle.object = text;
              								messageSequenceDAO.incrementSequence("app1", "keyA");
              				// fire the text message that will be routed to our MDP
              				try {
              					textMessageSender.sendMessage("without rollback");
              				} catch (Exception e) {
              					// Don't bother
              				// in case anything is warming up in our debugger we should
              				// pause to
              				// to allow the MDP code to execute
              				try {
              				} catch (InterruptedException e) {
              					// Don't bother
              				String fromMdp = null;
              				synchronized (handle) {
              					fromMdp = (String) handle.object;
              				assertEquals("without rollback", fromMdp);
              				// check the database update worked
              				sequence = 0;
              				sequence = messageSequenceDAO.readSequence("app1", "keyA");
              				assertEquals(2, sequence);
              Spring context addition:
              	<bean id="transactionTemplate" class="" scope="prototype">
              		<property name="transactionManager" ref="jtaTransactionManager" />
              The code presented above is not meant to be actually useful. It's just that I cannot really figure out what's wrong with it.