AnsweredAssumed Answered

Activiti controlling the transactions

Question asked by gopi.chitturi@gmail.com on Dec 12, 2018
Latest reply on Dec 21, 2018 by pault

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.

Outcomes