Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
开发团队
Flowable Engine
提交
3a9fbfa4
F
Flowable Engine
项目概览
开发团队
/
Flowable Engine
通知
9
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
F
Flowable Engine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
3a9fbfa4
编写于
5月 03, 2013
作者:
F
Frederik Heremans
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Added retry-mechanism (3 times)
上级
9d5f998f
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
37 addition
and
2 deletion
+37
-2
modules/activiti-engine/src/test/java/org/activiti/engine/test/concurrency/ConcurrentEngineUsageTest.java
...ti/engine/test/concurrency/ConcurrentEngineUsageTest.java
+37
-2
未找到文件。
modules/activiti-engine/src/test/java/org/activiti/engine/test/concurrency/ConcurrentEngineUsageTest.java
浏览文件 @
3a9fbfa4
...
...
@@ -24,6 +24,9 @@ import org.activiti.engine.impl.identity.Authentication;
import
org.activiti.engine.impl.test.PluggableActivitiTestCase
;
import
org.activiti.engine.task.Task
;
import
org.activiti.engine.test.Deployment
;
import
org.apache.ibatis.exceptions.PersistenceException
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
/**
...
...
@@ -33,6 +36,8 @@ import org.activiti.engine.test.Deployment;
*/
public
class
ConcurrentEngineUsageTest
extends
PluggableActivitiTestCase
{
private
static
Logger
log
=
LoggerFactory
.
getLogger
(
ConcurrentEngineUsageTest
.
class
);
@Deployment
public
void
testConcurrentUsage
()
throws
Exception
{
...
...
@@ -65,6 +70,34 @@ public class ConcurrentEngineUsageTest extends PluggableActivitiTestCase {
}
}
protected
void
retryStartProcess
(
String
runningUser
)
{
int
retries
=
3
;
boolean
success
=
false
;
while
(
retries
>
0
&&
!
success
)
{
try
{
runtimeService
.
startProcessInstanceByKey
(
"concurrentProcess"
,
Collections
.
singletonMap
(
"assignee"
,
(
Object
)
runningUser
));
success
=
true
;
}
catch
(
PersistenceException
pe
)
{
log
.
debug
(
"Retrying process start: "
+
pe
.
getMessage
());
retries
=
retries
-
1
;
}
}
}
protected
void
retryFinishTask
(
String
taskId
)
{
int
retries
=
3
;
boolean
success
=
false
;
while
(
retries
>
0
&&
!
success
)
{
try
{
taskService
.
complete
(
taskId
);
success
=
true
;
}
catch
(
PersistenceException
pe
)
{
retries
=
retries
-
1
;
log
.
debug
(
"Retrying task completion: "
+
pe
.
getMessage
());
}
}
}
private
class
ConcurrentProcessRunnerRunnable
implements
Runnable
{
private
String
drivingUser
;
...
...
@@ -86,7 +119,7 @@ public class ConcurrentEngineUsageTest extends PluggableActivitiTestCase {
{
if
(
numberOfProcesses
>
0
&&
!
finishTask
)
{
// Start a new process
r
untimeService
.
startProcessInstanceByKey
(
"concurrentProcess"
,
Collections
.
singletonMap
(
"assignee"
,
(
Object
)
drivingUser
)
);
r
etryStartProcess
(
drivingUser
);
finishTask
=
true
;
if
(
numberOfProcesses
==
0
)
{
...
...
@@ -98,7 +131,9 @@ public class ConcurrentEngineUsageTest extends PluggableActivitiTestCase {
// Finish a task
List
<
Task
>
taskToComplete
=
taskService
.
createTaskQuery
().
taskAssignee
(
drivingUser
).
listPage
(
0
,
1
);
tasksAvailable
=
taskToComplete
.
size
()
>
0
;
taskService
.
complete
(
taskToComplete
.
get
(
0
).
getId
());
if
(
tasksAvailable
)
{
retryFinishTask
(
taskToComplete
.
get
(
0
).
getId
());
}
finishTask
=
false
;
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录