Foren
Does ServiceBuilder allow for non-transactional public methods?
lucas theisen, geändert vor 11 Jahren.
Does ServiceBuilder allow for non-transactional public methods?
New Member Beiträge: 19 Beitrittsdatum: 02.03.11 Neueste Beiträge
Unless I am missing something, every public method in a liferay ServiceBuilder built service is transactional and there appears to be no way around it.
I have a non-model service (no column's in the entity) which i want to use to work with multiple other services. I define it thuslly (in service.xml):
Then i add an public interface method:
The idea here is that sendPending should be a public interface method, and updateAndSend should be a private helper that executes atomically (if anything fails while sending the message the model updates get rolled back), but @Transactional AOP requires public methods. Anyway, when I run service builder, the generated NotificationService.java interface ALWAYS has this annotation at the interface level:
And since the default propagation is REQUIRED, it seems that every generated method will be run in a transaction. There is a lot of work getting done in the sendPending method and I would like to avoid locking tables/columns/rows for the duration. Is there anyway around this?
I have a non-model service (no column's in the entity) which i want to use to work with multiple other services. I define it thuslly (in service.xml):
<entity name="Notification" local-service="false" remote-service="true" />
Then i add an public interface method:
@Override
public void sendPending( Date now, String toEmail ) {
...
updateAndSend( eventsToUpdate, messageToSend );
}
@Override
public void updateAndSend( List<event> eventsToUpdate, Message messageToSend ) throws SystemException, PortalException {
try {
for ( Event event : eventsToUpdate ) {
eventLocalService.updateEvent( event );
}
Transport.send( messageToSend );
}
catch ( Exception e ) {
throw new PortalException( e );
}
}
</event>
The idea here is that sendPending should be a public interface method, and updateAndSend should be a private helper that executes atomically (if anything fails while sending the message the model updates get rolled back), but @Transactional AOP requires public methods. Anyway, when I run service builder, the generated NotificationService.java interface ALWAYS has this annotation at the interface level:
@Transactional(isolation = Isolation.PORTAL, rollbackFor = {
PortalException.class, SystemException.class}
)
public interface NotificationService {
...
}
And since the default propagation is REQUIRED, it seems that every generated method will be run in a transaction. There is a lot of work getting done in the sendPending method and I would like to avoid locking tables/columns/rows for the duration. Is there anyway around this?
Marc-Andre Gauthier, geändert vor 6 Jahren.
RE: Does ServiceBuilder allow for non-transactional public methods?
New Member Beiträge: 21 Beitrittsdatum: 30.07.15 Neueste Beiträge
Ever got an answer on this?