Not able to create a ProcessEngine Bean to connect a different Data Source

cancel
Showing results for 
Search instead for 
Did you mean: 
gowtham1206
Member II

Not able to create a ProcessEngine Bean to connect a different Data Source

Hi,

I'm using Activiti community version. I've two databases with Activiti Data. One is the old database and another one is the new and primary database to which the ProcessEngine connects (The reason why we are not using ONE single database is we do not want to migrate the HISTORIC data from OLD database to new database). I'm looking to create a wrapper API service to pull the historic process and task instances from both the primary and old database.

This leads to the need of building a new process engine that connects the old database. I'm able to achieve this by building the process engine on runtime using ProcessEngineConfiguration by setting the old data source.

ProcessEngine processEngine = ProcessEngineConfiguration.
createStandaloneProcessEngineConfiguration().
setDataSource(oldDataSource).
buildProcessEngine();

Doing this way affects the performance as the wrapper service builds the engine on runtime. However, I'm not able to create a new bean to initialize the ProcessEngine with the old datasource

@Bean
public ProcessEngine processEngine1x() {
return ProcessEngineConfiguration.
createStandaloneProcessEngineConfiguration().
setDataSource(oldDataSource()).
buildProcessEngine();
}‍‍‍‍‍‍‍

Defining the process engine bean as above throws the below error.

***************************

APPLICATION FAILED TO START

***************************

 

Description:

 

Parameter 0 of method processEngineEndpoint in org.activiti.spring.boot.EndpointAutoConfiguration required a single bean, but 2 were found:

                - processEngine: defined by method 'processEngine' in class path resource [org/activiti/spring/boot/DataSourceProcessEngineAutoConfiguration$DataSourceProcessEngineConfiguration.class]

                - processEngine1x: defined by method 'processEngine1x' in class path resource [com/bnym/nwf/config/NWFConfig.class]

 

Action:

 

Consider marking one of the beans as @Primary, updating the consumer to accept multiple beans, or using @Qualifier to identify the bean that should be consumed

Is there any other feasible and optimized way of building a separate Process Engine to handle this scenario?

Thanks for the help.

1 Reply
cjose
Senior Member II

Re: Not able to create a ProcessEngine Bean to connect a different Data Source

From the error it is quite clear that is confused with the two process engine beans! A couple of options I can think of:

  1. Scheduled ETL job (using SQL/API) to migrate all the data from your main engine database to history database.
  2. Another option, wait until this issue is fixed in the Activiti 7 work that is happening now!

If you are interested in joining this work/contribution you can get in touch with the Activiti team on Gitter. You can find more details about the roadmap and milestones at - https://github.com/Activiti/Activiti/wiki/Activiti-7-Roadmap & https://activiti.gitbooks.io/activiti-7-developers-guide/

Ciju