Foros de discusión
Transaction issue when doing integration with spring framework
Ying Wang, modificado hace 7 años.
Transaction issue when doing integration with spring framework
Junior Member Mensajes: 36 Fecha de incorporación: 16/05/14 Mensajes recientes
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.
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.
'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, modificado hace 7 años.
RE: Transaction issue when doing integration with spring framework
Junior Member Mensajes: 36 Fecha de incorporación: 16/05/14 Mensajes recientes
Does anyone can help me on this question?