Hi,
I am using Activiti as our Business process orchestrator and I am running into an issue with transaction management. Here is the scenario:
1. Using Activiti 6 with Spring Boot (2.1.0)
2. Starting the process by RunTimeService
3. Using Service Task to perform business logic (my service task class is implementing JavaDelegate interface)
4. Running the process in Asynchronous mode (first service task is configured as Asynchronous)
5. Configured two different databases for Activiti and my Transactional system
@Configuration
public class ActivitiConfiguration extends AbstractProcessEngineAutoConfiguration {
@Bean
@ConfigurationProperties(prefix = "activiti.datasource")
public DataSource activitiDataSource() {
DataSource datasource = DataSourceBuilder.create().build();
return datasource;
}
@Bean
public SpringProcessEngineConfiguration springProcessEngineConfiguration(
PlatformTransactionManager transactionManager,
SpringAsyncExecutor springAsyncExecutor) throws IOException {
SpringProcessEngineConfiguration config = baseSpringProcessEngineConfiguration(
activitiDataSource(),
transactionManager,
springAsyncExecutor);
return config;
}
}
The issue I am facing is, the database operations I am performing in the Service Task classes (using Spring Data JPA) is not getting committed until the whole process is completed. Some times I am even not seeing the data committed to transnational database.
Following are the things I have tried but did not work:
1. Annotated the service method with @Transactional(propagation = Propagation.REQUIRES_NEW)
2.
@PersistenceContext
private EntityManager entityManager;
and
entityManager.persist(entity);
Any help would be really appreciated.
Did you manage to get this working ?
Wondering if it is because you have a transaction that spans two databases. I had strange behaviour in V5.22 when I indirectly had this situation, accessing two Process Engines using different databases in Execution Listeners and Service Tasks.
Even though your task is async, I think you'll still have part of your transaction in the Activiti database.
I seperated my code that worked with the external engine/database and explicitly ran it in a seperate thread, either waiting on a synchronised object, or allowing it run async as required - and then all was fine.
Might be worth a try to help understand what is going on at least.
Be interested to know if you've solved it another way, as may be relevant for my case as well.
Ask for and offer help to other Alfresco Process Services and Activiti Users and members of the Alfresco team.
By using this site, you are agreeing to allow us to collect and use cookies as outlined in Alfresco’s Cookie Statement and Terms of Use (and you have a legitimate interest in Alfresco and our products, authorizing us to contact you in such methods). If you are not ok with these terms, please do not use this website.