开发者

Spring Nested Transaction support on Bea Weblogic 10.3

开发者 https://www.devze.com 2023-03-02 03:46 出处:网络
i have a question for you. I have a component that have 2 methods. The first method needs to be attached to a outher transacion started from another component present into the chain (I use Spring Inte

i have a question for you. I have a component that have 2 methods. The first method needs to be attached to a outher transacion started from another component present into the chain (I use Spring Integration), and the second one that must be attached (for my application design) to anoter transaction. The behaviour that I want is that when the second method throw an Exception, the first method starts and itself re-attaching to the outher transaction to do his job. I try to use the "NESTED" propagation of Spring Framework to do this but without success.

This is the example:

public ComponentClassInterface{
         @Transactional(propagation = Propagation.REQUIRES_NEW, roll开发者_StackOverflow社区backFor=Exception.class) /*but i have used NESTED without success and I don't want use the same transaction */
         public ObjectMessage activate(ObjectMessage message);

}

public ComponentAbstractClass implements ComponentClassInterface{

       public void updateObjectMessage(ObjectMessage message){
              /*To obtain an attached instance of previously persisted message*/
              ObjectMessage message = daoMessage.getMessageByID(message.getID);/*Here i can't retreive the message...the transaction isn't yet attached*/
              message.setSomeProperty("ChangedPropertyValue");
              daoMessage.updateItem(message);
              }
       @Override
       public abstract ObjectMessage activate(ObjectMessage message);

}

public ComponentConcreteClass extends ComponentAbstractClass{
       @Override
       public ObjectMessage activate(ObjectMessage message){
              ............ doSomeStuff ............
       }

}

The objective is to find a solution that permits me to don't rewrite/rethink the application flow and mantain the classes as upon.

Regards

Damiano


Transactions in Spring are supported through AOP and proxies. This means that if a method of a class instance calls another method of the same instance, it doesn't invoke the method through a Spring proxy, and Spring can't intercept the call and start a new transaction for you. You need to put the method with the REQUIRES_NEW propagation inside another Spring component.

0

精彩评论

暂无评论...
验证码 换一张
取 消