AnsweredAssumed Answered

Issue with Clock and multiple engines

Question asked by tomaszk. on Nov 11, 2015
Latest reply on Nov 12, 2015 by tomaszk.
I would like to have to engines running in one Spring application. One engine would have clock set to current time, the other engine would be used to stage the data - so it would have clock that could change to past date. I have created two engines as shown below but for some reason changing clock in one engine changes it also in the other. Any idea why this might be happening? Is there a better way to do this?
Thanks!


<bean id="processEngineConfiguration" class="org.activiti.spring.SpringProcessEngineConfiguration">
   <property name="databaseType" value="mysql" />
   <property name="dataSource" ref="activitiDataSource" />
   <property name="transactionManager" ref="activitiTransactionManager" />
   <property name="databaseSchemaUpdate" value="true" />
   <property name="history" value="full" />
   <property name="jobExecutorActivate" value="false" />
</bean>
   
<bean id="historyProcessEngineConfiguration" class="org.activiti.spring.SpringProcessEngineConfiguration">
   <property name="databaseType" value="mysql" />
   <property name="dataSource" ref="activitiDataSource" />
   <property name="transactionManager" ref="activitiTransactionManager" />
   <property name="databaseSchemaUpdate" value="true" />
   <property name="history" value="full" />
   <property name="jobExecutorActivate" value="false" />
</bean>

<bean id="processEngine" class="org.activiti.spring.ProcessEngineFactoryBean">
   <property name="processEngineConfiguration" ref="processEngineConfiguration" />
</bean>
   
<bean id="histroyProcessEngine" class="org.activiti.spring.ProcessEngineFactoryBean">
   <property name="processEngineConfiguration" ref="historyProcessEngineConfiguration" />
</bean>



@Autowired
@Qualifier("processEngine")
ProcessEngine processEngine;

@Autowired
@Qualifier("histroyProcessEngine")
ProcessEngine histroyProcessEngine;

Calendar cal = Calendar.getInstance();
cal.set(Calendar.MONTH, Calendar.JANUARY);
histroyProcessEngine.getProcessEngineConfiguration().getClock().setCurrentCalendar(cal);
      
System.out.println(histroyProcessEngine.getProcessEngineConfiguration().getClock().getCurrentTime().toGMTString());
System.out.println(processEngine.getProcessEngineConfiguration().getClock().getCurrentTime().toGMTString());

Outcomes