activiti5第六弹 手动任务、接收任务、邮件任务
生活随笔
收集整理的這篇文章主要介紹了
activiti5第六弹 手动任务、接收任务、邮件任务
小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
手動(dòng)任務(wù)和接收任務(wù)幾乎不在程序中做什么事情---只是在流程的歷史中留下一點(diǎn)痕跡,表明流程是走過某些節(jié)點(diǎn)的。。。而且這兩個(gè)任務(wù)是無法用taskservice查詢到的
但是接收任務(wù)比手動(dòng)任務(wù)多一個(gè)功能,就是確認(rèn)功能。。。
activiti.cfg.xml配置
<?xml version="1.0"?> <beans default-lazy-init="false"xsi:schemaLocation=" http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.0.xsd http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-3.0.xsd http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd"xmlns:aop="http://www.springframework.org/schema/aop" xmlns:mvc="http://www.springframework.org/schema/mvc"xmlns:tx="http://www.springframework.org/schema/tx" xmlns:jee="http://www.springframework.org/schema/jee"xmlns:util="http://www.springframework.org/schema/util" xmlns:context="http://www.springframework.org/schema/context"xmlns:p="http://www.springframework.org/schema/p" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xmlns="http://www.springframework.org/schema/beans"><beanclass="org.activiti.engine.impl.cfg.StandaloneInMemProcessEngineConfiguration"id="processEngineConfiguration"><property name="jdbcUrl" value="jdbc:mysql://localhost:3306/activi1" /><property name="jdbcDriver" value="com.mysql.jdbc.Driver" /><property name="jdbcUsername" value="root" /><property name="jdbcPassword" value="root" /><property name="databaseSchemaUpdate" value="true" /><property name="jobExecutorActivate" value="true" /><property name="mailServerHost" value="smtp.163.com" />//郵件任務(wù)的配置如下<property name="mailServerPort" value="25" /><property name="mailServerUsername" value="15203437412"></property><property name="mailServerPassword" value="你的密碼"></property><property name="history" value="full"></property></bean> </beans>
首先是流程圖:
測試類:
package final_activiti.progress;import java.util.List;import org.activiti.engine.impl.test.PluggableActivitiTestCase; import org.activiti.engine.runtime.ProcessInstance; import org.activiti.engine.task.Task; import org.activiti.engine.test.Deployment; import org.junit.Test;public class ManualRecTest extends PluggableActivitiTestCase {@Test@Deployment(resources = "final_activiti/progress/RecAndManulTask.bpmn")public void test() {// 啟動(dòng)流程ProcessInstance pi = runtimeService.startProcessInstanceByKey("processRM");// 查詢當(dāng)前任務(wù)List<Task> tasks = taskService.createTaskQuery().list();// 斷言通過taskservice是無法查詢到這兩個(gè)任務(wù)的assertTrue(tasks.size() == 0);List<ProcessInstance> pis = runtimeService.createProcessInstanceQuery().list();// 斷言流程數(shù)為1,因?yàn)槲覇?dòng)了一個(gè)流程,而且這個(gè)流程仍然等待著接收任務(wù)的確認(rèn)而未完成assertTrue(pis.size() == 1);// 發(fā)出信號(hào)給receive任務(wù),讓流程繼續(xù)執(zhí)行runtimeService.signal(pi.getId());// 流程結(jié)束了··所以是0pis = runtimeService.createProcessInstanceQuery().list();assertTrue(pis.size() == 0);// 斷言流程結(jié)束assertProcessEnded(pi.getId());}}
測試結(jié)果是綠條。
郵件任務(wù):郵件任務(wù)也很簡單,功能當(dāng)然是發(fā)郵件
流程圖:
對(duì)MAIL TASK 進(jìn)行相應(yīng)的配置
測試類:
package final_activiti.progress;import org.activiti.engine.impl.test.PluggableActivitiTestCase; import org.activiti.engine.test.Deployment; import org.junit.Test;public class MailTest extends PluggableActivitiTestCase {@Test@Deployment(resources = "final_activiti/progress/MailTask.bpmn")public void test() {//直接開啟流程就好了runtimeService.startProcessInstanceByKey("mail");}}
總結(jié)
以上是生活随笔為你收集整理的activiti5第六弹 手动任务、接收任务、邮件任务的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 忘记mysql数据库连接密码
- 下一篇: JAVA:贪吃蛇源代码