Announcement Announcement Module
Collapse
No announcement yet.
Standalone JTA (Bitronix) + JPA (XA) JDBC + JPA JMS MDP (XA) ActiveMQ Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • 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.

    Comment


    • #17
      Working config with Atomikos

      Hi,

      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.

      Cheers
      Happy 2010

      Guy

      Comment


      • #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.

        Comment


        • #19
          Should be ok

          Hi,

          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.

          Best
          Guy

          Comment


          • #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:
            Code:
            	
            <property name="jpaProperties">
            <props>
            ...
            ...
               <prop key="eclipselink.target-server">my.spring.jtatest.AtomikosTransactionSessionCustomizer</prop>
               <prop key="jdbc.exclusive-connection.mode">Transactional</prop>
            ...
            ...
               </props>
            </property>
            target-server is the name of the class that will return an Atomikos UserTransaction when EclipseLink calls its method "acquireTransactionManager".

            2. TransactionSessionCustomizer class
            Code:
            package my.spring.jtatest;
            
            public class AtomikosTransactionSessionCustomizer extends JTATransactionController {
            
            
            @Override
              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"
            Code:
            <persistence xmlns="http://java.sun.com/xml/ns/persistence" version="1.0">
            
              <persistence-unit name="SpringJpaTest" transaction-type="JTA">
            	<jta-data-source>jdbc/MyDB2DB</jta-data-source>
            </persistence-unit>
            	
            </persistence>
            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.

            Comment


            • #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:

              Code:
              	public void testJmsRecieveWithDatabaseUpdate() throws Exception {
              		assertNotNull(textMessageDelegate);
              		assertNotNull(textMessageSender);
              
              		TransactionTemplate transactionTemplate = (TransactionTemplate) applicationContext
              				.getBean("transactionTemplate");
              
              		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
              					e.printStackTrace();
              				}
              
              				// in case anything is warming up in our debugger we should
              				// pause to
              				// to allow the MDP code to execute
              
              				try {
              					Thread.sleep(1000);
              				} catch (InterruptedException e) {
              					// Don't bother
              					e.printStackTrace();
              				}
              
              				String fromMdp = null;
              
              				synchronized (handle) {
              					fromMdp = (String) handle.object;
              				}
              
              				assertNotNull(fromMdp);
              				assertEquals("without rollback", fromMdp);
              
              				// check the database update worked
              				sequence = 0;
              				sequence = messageSequenceDAO.readSequence("app1", "keyA");
              
              				assertEquals(2, sequence);
              			}
              		});
              	}
              Spring context addition:
              Code:
              	<bean id="transactionTemplate" class="org.springframework.transaction.support.TransactionTemplate" scope="prototype">
              		<property name="transactionManager" ref="jtaTransactionManager" />
              	</bean>
              P.S.
              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.

              Comment

              Working...
              X