码迷,mamicode.com
首页 > 其他好文 > 详细

工作流性能优化(敢问activiti有扩展性?)(2)

时间:2015-04-23 19:27:26      阅读:388      评论:0      收藏:0      [点我收藏+]

标签:

2015/4/17

粗略看了activiti的sql的,在ativity engine包里边;

没什么头绪,先用excel记录数据量少的时候本机的性能情况;

 

不打印hibernate的sql;一刷一大片,还不输出参数是什么,这样的语句有什么意义哦,怀念mybatis;

<property name="showSql" value="false" />

 

让程序充分加载,取第三次的结果:

开始时间:2015-04-17 09:38:20.611

总记录数:57

结束时间:2015-04-17 09:38:22.788

总耗时:2177毫秒。

开始时间:2015-04-17 09:39:24.174

总记录数:57

结束时间:2015-04-17 09:39:26.110

总耗时:1936毫秒。

开始时间:2015-04-17 09:39:30.521

总记录数:57

结束时间:2015-04-17 09:39:32.331

总耗时:1810毫秒。

 

设置打印activiti中mybatis的sql;

<logger name="org.apache.ibatis.jdbc.ScriptRunner" level="DEBUG"/>

<!-- 目前本人只知道这句最有用 -->

<logger name="org.activiti.engine.impl.persistence.entity" level="DEBUG"/>

<!-- 下面是其他帖子抄的不知道有什么用 -->

<logger name="java.sql.Connection" level="DEBUG"/>

<logger name="java.sql.Statement" level="DEBUG"/>

<logger name="java.sql.PreparedStatement" level="DEBUG"/>

<logger name="java.sql.ResultSet" level="DEBUG"/>

 

配置logback;

slf4j包冲突的,在pom.xml里边指定slf4j的版本就可以;

 

数据语句:

2015-04-17 10:25:30.487 DEBUG org.activiti.engine.impl.persistence.entity.HistoricProcessInstanceEntity.selectHistoricProcessInstancesByQueryCriteria - ooo Using Connection [Transaction-aware proxy for target Connection from DataSource [org.springframework.jdbc.datasource.DriverManagerDataSource@192db17]]

2015-04-17 10:25:30.487 DEBUG org.activiti.engine.impl.persistence.entity.HistoricProcessInstanceEntity.selectHistoricProcessInstancesByQueryCriteria - ==> Preparing: select RES.* from ACT_HI_PROCINST RES WHERE ( exists(select LINK.USER_ID_ from ACT_HI_IDENTITYLINK LINK where USER_ID_ = ? and LINK.PROC_INST_ID_ = RES.ID_) ) order by RES.START_TIME_ desc LIMIT ? OFFSET ?

2015-04-17 10:25:30.488 DEBUG org.activiti.engine.impl.persistence.entity.HistoricProcessInstanceEntity.selectHistoricProcessInstancesByQueryCriteria - ==> Parameters: 324(String), 2147483647(Integer), 0(Integer)

爱死mybatis,要啥有啥;

 

这里感觉没分页啊;

找出涉及哪些表,然后手工拼接数据,成功插入了1条数据;

写程序插入数据;

NM,activiti新增条记录都n麻烦,能不能好好编程了;

技术分享

 

换mysql存储过程,不错哦;

delimiter $$

use `keyan2`$$

drop procedure if exists `insert_task`$$

create definer=`root`@`localhost` procedure `insert_task`()

begin

declare beginId int default 100000;

declare detailId int default 100000;

declare actinstId int default 100000;

declare actinstId_org int default 100000;

declare varinstId int default 100000;

declare PROC_DEF_ID_ varchar(255) default ‘process_38869:8:87533‘;

declare ACT_ID_ varchar(255) default ‘sid-6EFEBB5D-1A5A-4737-TEST-A255D5‘;

declare TASK_DEF_KEY_ varchar(255) default ‘sid-6EFEBB5D-1A5A-4737-TEST-A255D8‘;

declare num int default 0;

while num < 1000 do

insert into `keyan2`.`act_ru_execution` (`ID_`, `REV_`, `PROC_INST_ID_`, `PROC_DEF_ID_`, `ACT_ID_`, `IS_ACTIVE_`, `IS_CONCURRENT_`, `IS_SCOPE_`, `IS_EVENT_SCOPE_`, `SUSPENSION_STATE_`,

`CACHED_ENT_STATE_`) values (beginId, ‘1‘, beginId, PROC_DEF_ID_, concat(ACT_ID_, beginId), ‘1‘, ‘0‘, ‘1‘, ‘0‘, ‘1‘, ‘2‘);

insert into `keyan2`.`act_ru_task` (`ID_`, `REV_`, `EXECUTION_ID_`, `PROC_INST_ID_`, `PROC_DEF_ID_`, `NAME_`, `TASK_DEF_KEY_`, `ASSIGNEE_`, `PRIORITY_`, `CREATE_TIME_`, `SUSPENSION_STATE_`)

values (beginId, ‘1‘, beginId, beginId, PROC_DEF_ID_, ‘编制‘, concat(TASK_DEF_KEY_, beginId), ‘324‘, ‘50‘, now(), ‘1‘);

insert into `keyan2`.`act_hi_taskinst` (`ID_`, `PROC_DEF_ID_`, `TASK_DEF_KEY_`, `PROC_INST_ID_`, `EXECUTION_ID_`, `NAME_`, `ASSIGNEE_`, `START_TIME_`, `PRIORITY_`)

values (beginId, PROC_DEF_ID_, concat(TASK_DEF_KEY_, beginId), beginId, beginId, ‘编制‘, ‘324‘, now(), ‘50‘);

insert into `keyan2`.`act_hi_procinst` (`ID_`, `PROC_INST_ID_`, `PROC_DEF_ID_`, `START_TIME_`, `START_USER_ID_`, `START_ACT_ID_`)

values (beginId, beginId, PROC_DEF_ID_, now(), ‘324‘, concat(ACT_ID_, beginId));

insert into `keyan2`.`act_hi_detail` (`ID_`, `TYPE_`, `PROC_INST_ID_`, `EXECUTION_ID_`, `NAME_`, `VAR_TYPE_`, `REV_`, `TIME_`, `TEXT_`)

values (detailId, ‘VariableUpdate‘, beginId, beginId, ‘user0‘, ‘string‘, ‘0‘, now(),‘324‘);

set detailId=detailId+1;

insert into `keyan2`.`act_hi_detail` (`ID_`, `TYPE_`, `PROC_INST_ID_`, `EXECUTION_ID_`, `NAME_`, `VAR_TYPE_`, `REV_`, `TIME_`, `TEXT_`,`ACT_INST_ID_`)

values (detailId, ‘VariableUpdate‘, beginId, beginId, ‘$category$‘, ‘string‘, ‘0‘, now(),‘information‘, actinstId);

set detailId=detailId+1;

insert into `keyan2`.`act_hi_detail` (`ID_`, `TYPE_`, `PROC_INST_ID_`, `EXECUTION_ID_`, `NAME_`, `VAR_TYPE_`, `REV_`, `TIME_`, `TEXT_`,`ACT_INST_ID_`)

values (detailId, ‘VariableUpdate‘, beginId, beginId, ‘$processDefinitionKey$‘, ‘string‘, ‘0‘, now(),‘process_38869‘, actinstId);

set detailId=detailId+1;

insert into `keyan2`.`act_hi_detail` (`ID_`, `TYPE_`, `PROC_INST_ID_`, `EXECUTION_ID_`, `NAME_`, `VAR_TYPE_`, `REV_`, `TIME_`, `TEXT_`,`ACT_INST_ID_`, `LONG_`)

values (detailId, ‘VariableUpdate‘, beginId, beginId, ‘$startUser$‘, ‘long‘, ‘0‘, now(),‘324‘, actinstId, ‘324‘);

set detailId=detailId+1;

insert into `keyan2`.`act_hi_detail` (`ID_`, `TYPE_`, `PROC_INST_ID_`, `EXECUTION_ID_`, `NAME_`, `VAR_TYPE_`, `REV_`, `TIME_`, `TEXT_`,`ACT_INST_ID_`)

values (detailId, ‘VariableUpdate‘, beginId, beginId, ‘$title$‘, ‘string‘, ‘0‘, now(), concat(‘TEST‘, beginId), actinstId);

set detailId=detailId+1;

insert into `keyan2`.`act_hi_detail` (`ID_`, `TYPE_`, `PROC_INST_ID_`, `EXECUTION_ID_`, `NAME_`, `VAR_TYPE_`, `REV_`, `TIME_`, `ACT_INST_ID_`, `BYTEARRAY_ID_`)

values (detailId, ‘VariableUpdate‘, beginId, beginId, ‘$start#91462.formDefinition$‘, ‘serializable‘, ‘0‘, now(), actinstId, ‘91480‘);

set detailId=detailId+1;

insert into `keyan2`.`act_hi_detail` (`ID_`, `TYPE_`, `PROC_INST_ID_`, `EXECUTION_ID_`, `NAME_`, `VAR_TYPE_`, `REV_`, `TIME_`, `ACT_INST_ID_`, `BYTEARRAY_ID_`)

values (detailId, ‘VariableUpdate‘, beginId, beginId, ‘$projectNode$‘, ‘bytes‘, ‘0‘, now(), actinstId, ‘91485‘);

set actinstId_org = actinstId;

insert into `keyan2`.`act_hi_actinst` (`ID_`, `PROC_DEF_ID_`, `PROC_INST_ID_`, `EXECUTION_ID_`, `ACT_ID_`, `ACT_NAME_`, `ACT_TYPE_`, `START_TIME_`, `END_TIME_`, `DURATION_`)

values (actinstId, PROC_DEF_ID_, beginId, beginId, concat(‘sid-6EFEBB5D-1A5A-4737-TEST-A255D8‘, actinstId), ‘开始‘, ‘startEvent‘, now(), now(), ‘0‘);

set actinstId = actinstId+1;

insert into `keyan2`.`act_hi_actinst` (`ID_`, `PROC_DEF_ID_`, `PROC_INST_ID_`, `EXECUTION_ID_`, `ACT_ID_`, `TASK_ID_`, `ACT_NAME_`, `ACT_TYPE_`, `ASSIGNEE_`, `START_TIME_`)

values (actinstId, PROC_DEF_ID_, beginId, beginId, concat(‘sid-6EFEBB5D-1A5A-4737-TEST-A255D8‘, actinstId), actinstId_org, ‘编制‘, ‘userTask‘, ‘324‘, now());

insert into `keyan2`.`act_hi_identitylink` (`ID_`, `TYPE_`, `USER_ID_`, `PROC_INST_ID_`) values (beginId, ‘starter‘, ‘324‘, beginId);

insert into `keyan2`.`act_hi_varinst` (`ID_`, `PROC_INST_ID_`, `EXECUTION_ID_`, `NAME_`, `VAR_TYPE_`, `REV_`, `TEXT_`)

values (varinstId, beginId, beginId, ‘user0‘, ‘string‘, ‘0‘, ‘324‘);

set varinstId = varinstId + 1;

insert into `keyan2`.`act_hi_varinst` (`ID_`, `PROC_INST_ID_`, `EXECUTION_ID_`, `NAME_`, `VAR_TYPE_`, `REV_`, `TEXT_`)

values (varinstId, beginId, beginId, ‘$category$‘, ‘string‘, ‘0‘, ‘information‘);

set varinstId = varinstId + 1;

insert into `keyan2`.`act_hi_varinst` (`ID_`, `PROC_INST_ID_`, `EXECUTION_ID_`, `NAME_`, `VAR_TYPE_`, `REV_`, `TEXT_`)

values (varinstId, beginId, beginId, ‘$processDefinitionKey$‘, ‘string‘, ‘0‘, ‘process_38869‘);

set varinstId = varinstId + 1;

insert into `keyan2`.`act_hi_varinst` (`ID_`, `PROC_INST_ID_`, `EXECUTION_ID_`, `NAME_`, `VAR_TYPE_`, `REV_`, `TEXT_`, `LONG_`)

values (varinstId, beginId, beginId, ‘$startUser$‘, ‘long‘, ‘0‘, ‘324‘, ‘324‘);

set varinstId = varinstId + 1;

insert into `keyan2`.`act_hi_varinst` (`ID_`, `PROC_INST_ID_`, `EXECUTION_ID_`, `NAME_`, `VAR_TYPE_`, `REV_`, `TEXT_`)

values (varinstId, beginId, beginId, ‘$title$‘, ‘string‘, ‘0‘, concat(‘TEST‘, beginId));

set varinstId = varinstId + 1;

insert into `keyan2`.`act_hi_varinst` (`ID_`, `PROC_INST_ID_`, `EXECUTION_ID_`, `NAME_`, `VAR_TYPE_`, `REV_`, `BYTEARRAY_ID_`)

values (varinstId, beginId, beginId, ‘$start#91462.formDefinition$‘, ‘serializable‘, ‘0‘, ‘91479‘);

set varinstId = varinstId + 1;

insert into `keyan2`.`act_hi_varinst` (`ID_`, `PROC_INST_ID_`, `EXECUTION_ID_`, `NAME_`, `VAR_TYPE_`, `REV_`, `BYTEARRAY_ID_`)

values (varinstId, beginId, beginId, ‘$projectNode$‘, ‘bytes‘, ‘0‘, ‘91484‘);

set num = num + 1;

set beginId = beginId + 1;

set detailId = detailId + 1;

set actinstId = actinstId + 1;

set varinstId = varinstId + 1;

end while;

end$$

delimiter ;

 

发现这activiti傻的,取出所有待办数据,然后在程序里边过滤数据,然后再做分页查询;

生成了1000数据,测试一把:

技术分享

 

明显地分页优化完胜,问了下LTW优化的兄弟;回答是:因为原有的配置,就是不加LoadTimeWeaver的配置,会导致ORM的LazyLoad无效,等同于所有关联的实体都会被加载;

 

分页优化还要改很多代码,activiti缺乏灵活性真的有体会了;

不行咱就自己写SQL;

先试试代码上改吧;

/org/activiti/db/mapping/entity/HistoricProcessInstance.xml竟然没有关联act_hi_taskinst的地方;

 

什么鬼,这能算优秀框架吗?我加个.variableValueEquals("ASSIGNEE_", String.valueOf(userInfo.getId()))查询,出来这样的语句,select count(distinct RES.ID_) from ACT_HI_PROCINST RES inner join ACT_HI_VARINST A0 on RES.PROC_INST_ID_ = A0.PROC_INST_ID_ WHERE RES.END_TIME_ IS NULL and ( exists(select LINK.USER_ID_ from ACT_HI_IDENTITYLINK LINK where USER_ID_ = ? and LINK.PROC_INST_ID_ = RES.ID_) ) and A0.NAME_= ? and A0.VAR_TYPE_ = ? and A0.TEXT_ = ?,Parameters: 324(String), ASSIGNEE_(String), string(String), 324(String),什么龟?

 

还得深入mapper.xml文件看看;

又纠结了,这怎么办?

工作流性能优化(敢问activiti有扩展性?)(2)

标签:

原文地址:http://www.cnblogs.com/yejq/p/4451148.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!