【发布时间】:2021-09-01 09:58:36
【问题描述】:
Camunda 通常使用 UUID(例如 98631715-0b07-11ec-ab3b-68545a6e5055)作为流程实例 ID。在我的项目中,正在生成像 124 这样的流程实例 ID,这在我看来很可疑。
可以如下所述重现此行为。
第 1 步
查看this repository 并启动流程引擎
这样他们都使用同一个共享数据库。
第 2 步
在 http://localhost:8080 登录 Camunda UI 并导航到任务列表。
在任务列表中启动Starter process。
第 3 步
前往驾驶舱并导航至Running process instances (http://localhost:8080/camunda/app/cockpit/default/#/processes)。
点击DomainProcess。
在ID 列中,您将看到一个数字(上面屏幕截图中的135)流程实例ID,而不是UUID。
错误的可能原因
在core-processs 引擎中,我有以下Config 类:
import org.camunda.bpm.engine.impl.history.HistoryLevel;
import org.camunda.bpm.engine.impl.history.event.HistoryEvent;
import org.camunda.bpm.engine.impl.history.handler.CompositeHistoryEventHandler;
import org.camunda.bpm.engine.impl.history.handler.HistoryEventHandler;
import org.camunda.bpm.engine.spring.SpringProcessEngineConfiguration;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.io.Resource;
import org.springframework.core.io.support.ResourcePatternResolver;
import org.springframework.transaction.PlatformTransactionManager;
import javax.sql.DataSource;
import java.io.IOException;
import java.util.Collections;
import java.util.List;
import static org.apache.commons.lang3.ArrayUtils.addAll;
@Configuration
public class Config {
private static final Logger LOGGER = LoggerFactory.getLogger(Config.class);
@Autowired
@Qualifier("camundaBpmDataSource")
private DataSource dataSource;
@Autowired
@Qualifier("camundaTxManager")
private PlatformTransactionManager txManager;
@Autowired
private ResourcePatternResolver resourceLoader;
@Bean
public SpringProcessEngineConfiguration processEngineConfiguration() {
final SpringProcessEngineConfiguration config = new SpringProcessEngineConfiguration();
config.setDataSource(dataSource);
config.setTransactionManager(txManager);
config.setDatabaseSchemaUpdate("true");
config.setHistory(HistoryLevel.HISTORY_LEVEL_FULL.getName());
config.setJobExecutorActivate(true);
config.setMetricsEnabled(false);
final Logger logger = LoggerFactory.getLogger("History Event Handler");
final HistoryEventHandler testHistoryEventHandler = new HistoryEventHandler() {
@Override
public void handleEvent(final HistoryEvent evt) {
LOGGER.debug("handleEvent | " + evt.getProcessInstanceId() + " | "
+ evt.toString());
}
@Override
public void handleEvents(final List<HistoryEvent> events) {
for (final HistoryEvent curEvent : events) {
handleEvent(curEvent);
}
}
};
config.setHistoryEventHandler(new CompositeHistoryEventHandler(Collections.singletonList(testHistoryEventHandler)));
try {
final Resource[] bpmnResources = resourceLoader.getResources("classpath:*.bpmn");
final Resource[] dmnResources = resourceLoader.getResources("classpath:*.dmn");
config.setDeploymentResources(addAll(bpmnResources, dmnResources));
} catch (final IOException exception) {
exception.printStackTrace();
LOGGER.error("An error occurred while trying to deploy BPMN and DMN files", exception);
}
return config;
}
}
如果我删除此配置(或注释@Configuration 行),错误就会消失。
问题
为什么在这种情况下,Camunda 会生成数字流程实例 ID(而不是像其他情况下那样生成 UUID)?
【问题讨论】:
-
您在寻找app.camunda.com/jira 吗?
-
@tevemadar 我不确定这是不是一个实际的缺陷。