First, the cause intends to use Activiti timed start event to start the process on a timed basis, and then start another process instance for each user in the process to calculate the real-time bill for each user, the number of users of the system is generally 1000~2000 (this is assumed to be 2000), Real-time bills are usually calculated hourly, then the day's data is 2000x24=48000, one months is 150w, a year is 1800w, so the number of records for Activiti history table is a bit more, it is doubtful whether he can run more smoothly under such data volume.I think Activiti design is not designed to do this kind of large-scale automatic triggering, no human participation in the process.
So it's not possible to make this automated process without writing a history table by some settings, but other processes that need to be manually involved are still able to record the history normally.
Second, source reading
then read the Activiti 5.18 source code, analysis is as follows:
Write history is expressed in Defaulthistorymanager, implemented by Historylevel to control, the relevant code is as follows:
public void recordProcessInstanceStart(ExecutionEntity processInstance) {
if(isHistoryLevelAtLeast(HistoryLevel.ACTIVITY)) {
HistoricProcessInstanceEntity historicProcessInstance = new HistoricProcessInstanceEntity(processInstance);
// Insert historic process-instance
getDbSqlSession().insert(historicProcessInstance);
....
}
The implementation of Ishistorylevelatleast is as follows:
public boolean isHistoryLevelAtLeast(HistoryLevel level) {
if(log.isDebugEnabled()) {
log.debug("Current history level: {}, level required: {}", historyLevel, level);
}
// Comparing enums actually compares the location of values declared in the enum
return historyLevel.isAtLeast(level);
}
The Historylevel enumeration type is implemented as follows
/**
* Enum that contains all possible history-levels.
*
* @author Frederik Heremans
*/
public enum HistoryLevel {
NONE("none"),
ACTIVITY("activity"),
AUDIT("audit"),
FULL("full");
private String key;
private HistoryLevel(String key) {
this.key = key;
}
/**
* @param key string representation of level
* @return {@link HistoryLevel} for the given key
* @throws ActivitiException when passed in key doesn‘t correspond to existing level
*/
public static HistoryLevel getHistoryLevelForKey(String key) {
for(HistoryLevel level : values()) {
if(level.key.equals(key)) {
return level;
}
}
throw new ActivitiIllegalArgumentException("Illegal value for history-level: " + key);
}
/**
* String representation of this history-level.
*/
public String getKey() {
return key;
}
/**
* Checks if the given level is the same as, or higher in order than the
* level this method is executed on.
*/
public boolean isAtLeast(HistoryLevel level) {
// Comparing enums actually compares the location of values declared in the enum
return this.compareTo(level) >= 0;
}
}
As you can see, it is up to the level members of the Defaulthistorymanager to record the process execution information in the history table, which is only recorded at activity and above. Defaulthistorymanager is global and is not related to a specific process or process instance, so in the default implementation, Activiti does not support setting up a single process or whether a process instance writes a history table.Third, the solution if we really want to implement for each process or process instance can control whether he writes a log, There are two changes: 1. To add a Historylevel attribute, or process variable, to a executionentity, it is more convenient to use a process variable, and there is no need to change the original class; 2. To implement a custom historymanager, and then inject it into the Commandcont Ext. In this custom historymanager, you need to be able to judge the level of Executionentity's historylevel in order to decide whether or not to record his historical information;
From for notes (Wiz)
Activiti Series: Is it possible to write information about certain processes to a history table while others do not?