use of org.activiti.engine.impl.interceptor.RetryInterceptor in project Activiti by Activiti.
the class RetryInterceptorTest method testRetryInterceptor.
public void testRetryInterceptor() {
RetryInterceptor retryInterceptor = new RetryInterceptor();
retryInterceptor.setNext(new CommandInvoker());
try {
retryInterceptor.execute(new CommandConfig(), new CommandThrowingOptimisticLockingException());
fail("ActivitiException expected.");
} catch (ActivitiException e) {
assertTrue(e.getMessage().contains(retryInterceptor.getNumOfRetries() + " retries failed"));
}
}
use of org.activiti.engine.impl.interceptor.RetryInterceptor in project Activiti by Activiti.
the class CompetingSignalsTest method testCompetingSignalsWithRetry.
@Deployment(resources = { "org/activiti/engine/test/concurrency/CompetingSignalsTest.testCompetingSignals.bpmn20.xml" })
public void testCompetingSignalsWithRetry() throws Exception {
RuntimeServiceImpl runtimeServiceImpl = (RuntimeServiceImpl) runtimeService;
CommandExecutorImpl before = (CommandExecutorImpl) runtimeServiceImpl.getCommandExecutor();
try {
CommandInterceptor retryInterceptor = new RetryInterceptor();
retryInterceptor.setNext(before.getFirst());
runtimeServiceImpl.setCommandExecutor(new CommandExecutorImpl(before.getDefaultConfig(), retryInterceptor));
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("CompetingSignalsProcess");
String processInstanceId = processInstance.getId();
log.debug("test thread starts thread one");
SignalThread threadOne = new SignalThread(processInstanceId);
threadOne.startAndWaitUntilControlIsReturned();
log.debug("test thread continues to start thread two");
SignalThread threadTwo = new SignalThread(processInstanceId);
threadTwo.startAndWaitUntilControlIsReturned();
log.debug("test thread notifies thread 1");
threadOne.proceedAndWaitTillDone();
assertNull(threadOne.exception);
log.debug("test thread notifies thread 2");
threadTwo.proceedAndWaitTillDone();
assertNull(threadTwo.exception);
} finally {
// restore the command executor
runtimeServiceImpl.setCommandExecutor(before);
}
}
use of org.activiti.engine.impl.interceptor.RetryInterceptor in project Activiti by Activiti.
the class RetryInterceptorTest method setupProcessEngine.
@Before
public void setupProcessEngine() {
ProcessEngineConfigurationImpl processEngineConfiguration = (ProcessEngineConfigurationImpl) new StandaloneInMemProcessEngineConfiguration();
processEngineConfiguration.setJdbcUrl("jdbc:h2:mem:retryInterceptorTest");
List<CommandInterceptor> interceptors = new ArrayList<CommandInterceptor>();
retryInterceptor = new RetryInterceptor();
interceptors.add(retryInterceptor);
processEngineConfiguration.setCustomPreCommandInterceptors(interceptors);
processEngine = processEngineConfiguration.buildProcessEngine();
}
Aggregations