0
votes

Do I need an application server for transaction management?, really.

My question is for Spring framework. They said (Spring Documentation),

http://static.springsource.org/spring/docs/3.1.x/spring-framework-reference/html/transaction.html#d0e20594

"Typically you need an application server's JTA capability only if your application needs to handle transactions across multiple resources", I use Jboss AS Server and JBoss can provide connections from a connection pool and manage transactions. My configuration file use (local):

<!-- Transaction Config -->
<bean id="transactionManager"
      class="org.springframework.orm.hibernate3.HibernateTransactionManager"
      p:sessionFactory-ref="sessionFactory"/>

Do I need to change to (Global):

<bean id="txManager" 
      class="org.springframework.transaction.jta.JtaTransactionManager"/>

I order to use connection pool from Jboss. Spring documentation say :

In particular, you do not need an application server simply for declarative transactions through EJBs. In fact, even if your application server has powerful JTA capabilities, you may decide that the Spring Framework's declarative transactions offer more power and a more productive programming model than EJB CMT. Thanks.

2
I guess you have answer in your question itself. You can use either app server based TM or use Spring TMVishal Biyani

2 Answers

2
votes

Usage of ApplicationServer to provide transaction management depends on what is your usecase,

If your transaction is distributed (spanning multiple parties) then you would like to use JTA transaction capabilities, for plain database transaction you dont need application server and Spring built in transaction capability is more than enough.

Though it also depends on your architecture defined for your application, at some organization it is kind of a practice to use JTA even though the transaction boundary is limited and doesn't require distributed transaction.

You may wish to read something about distributed transaction to decide if you would need JTA or just Spring local transaction.

Some references:

http://www.javaworld.com/javaworld/jw-04-2007/jw-04-xa.html

http://en.wikipedia.org/wiki/Java_Transaction_API

0
votes

This is what spring source has to say about your question:

Is an application server needed for transaction management?

The Spring Framework's transaction management support significantly changes traditional thinking as to when a J2EE application requires an application server. In particular, you don't need an application server just to have declarative transactions via EJB. In fact, even if you have an application server with powerful JTA capabilities, you may well decide that the Spring Framework's declarative transactions offer more power and a much more productive programming model than EJB CMT. Typically you need an application server's JTA capability only if you need to enlist multiple transactional resources, and for many applications being able to handle transactions across multiple resources isn't a requirement. For example, many high-end applications use a single, highly scalable database (such as Oracle 9i RAC). Standalone transaction managers such as Atomikos Transactions and JOTM are other options. (Of course you may need other application server capabilities such as JMS and JCA.) The most important point is that with the Spring Framework you can choose when to scale your application up to a full-blown application server. Gone are the days when the only alternative to using EJB CMT or JTA was to write code using local transactions such as those on JDBC connections, and face a hefty rework if you ever needed that code to run within global, container-managed transactions. With the Spring Framework, only configuration needs to change so that your code doesn't have to.

More Detail..