Optimal configuration @EnableTransactionManagement

I am quite confused by this topic and see very few tips in the Spring 4.x documentation. First of all, let me say that I can customize my project in any way. Static weaving, compilation in time, no, etc.

I just want the best performance. But if the differences in performance are microseconds, then I just want the simplest. I only care about the difference in performance that would affect my customers.

Ok, so here are the relevant options:

  • adviceMode = proxy, proxyTargetclass = true
  • adviceMode = proxy, proxyTargetclass = false
  • adviceMode = aspectJ, compilation over time
  • adviceMode = aspectJ, weaving at boot time

I agree to add some time to initialize my application while it runs fast.

So, what are the tradeoffs between these four ways to set up transaction management?

Are there tradeoffs or is it just a performance issue?

Please note that I am using Spring 4.0.2 and Java 1.7. If there is Spring 4.0 documentation that basically answers this question, then I apologize and just redirect me to the document. So far I have seen documentation on how to configure them, but not how they compare. Thanks!

Also note that most of the information on the Internet about this is really out of date. Therefore, I am looking for current comparisons.

+7
spring spring-transactions aspectj-maven-plugin
source share
1 answer

This configuration specifies how the transaction aspect will be applied. In short:

adviceMode = proxy, proxyTargetclass = true Cglib is used as a proxy mechanism. If you use this, cglib must be in the classpath, your proxied classes must have a nonparametric constructor, and they cannot be final (cglib creates the child class as a proxy).

adviceMode = proxy, proxyTargetclass = false The Jdk proxy mechanism is used. You can only proxy classes that implement the interface for methods that must be transactional. The Jdk proxy server can be classed, but cannot be entered as a proxy source class.

So, for adviceMode = proxies, the solution depends more on how your code standards and what restrictions stem from the proxy mechanism used.

adviceMode = aspectJ uses the aspectJ library, which performs byte binding instead of proxying.

adviceMode = aspectJ, compilation over time During the build process, you should use the aspectJ toolkit.

adviceMode = aspectJ, load time The toolkit runs at run time. You must put the aspectj agent as the jvm parameter.

Using aspectJ is more powerful and probably more advanced. It is also less invasive in terms of restrictions on the classes you want to be transactional. However, proxy mode is simple Spring from a turnkey solution.

More details about the proxy are here http://docs.spring.io/spring/docs/3.0.0.M3/reference/html/ch08s06.html . Read more about aspectJ with Spring here http://docs.spring.io/spring/docs/3.0.0.M4/reference/html/ch07s08.html .

+6
source share

All Articles