Forums de discussion

Transaction issue when doing integration with spring framework

Ying Wang, modifié il y a 7 années.

Transaction issue when doing integration with spring framework

Junior Member Publications: 36 Date d'inscription: 16/05/14 Publications récentes
Recently I focused on a project. It needs to subscribe JMS message. I am using 'spring integration' framework , integrate it with liferay portlet, so that it can be more easily deployed in liferay server container.
'spring integration' framework has its own service component. We use @Service , @Transactional annotations in the service bean. I invoked two service build method in my own spring service. But I found that they are not controlled under same transaction. My code is like following.

@Service
public class UserSyncService{
                  @Transactional
                  public void userSynchronize(){
                          .....
                             UserLocalServiceUtil.addUser();
                              
                          if(true){
                                    throw new Exception()
                            }
                            FooLocalServiceUtil.addFoo();
                  }
}

The running result of this piece of code is that 'user ' object is still created successfully. I found Liferay Service Build automatically created some spring code which include a 'liferaytransactionManager' bean definition. But my own spring service seems can not use liferay's transactionManager. Maybe there is some way, but I don't know. So I have to define my own transactionManager. I suppose the cause of my problem is that they are two isolated different transactionManager, so they can not be used at sam e time .
Does anyone have some experience on this kind of issue.
My question is: How to use transaction when liferay integrated with spring framework.
Ying Wang, modifié il y a 7 années.

RE: Transaction issue when doing integration with spring framework

Junior Member Publications: 36 Date d'inscription: 16/05/14 Publications récentes
Does anyone can help me on this question?