简体   繁体   English

在Activiti Explorer外部启动Activiti进程,并在Activiti Explorer内完成它

[英]Starting a activiti process outside activiti explorer and completing it inside activiti explorer

我对activiti不太熟悉,我想知道有什么方法可以仅使用Java代码在Activiti Explorer中部署甚至启动一个过程,即运行Java应用程序为kermit创建任务,然后登录到Activiti Explorer并完成它。

Sure, this is possible via the Activiti REST API and via the Activiti Java APIs. 当然,可以通过Activiti REST API和Activiti Java API来实现。

If you want to start processes inside your own java application, you can setup a java maven project and import the necessary Activiti APIs ( http://activiti.org/community.html ) 如果要在自己的Java应用程序中启动进程,则可以设置一个Java Maven项目并导入必要的Activiti API( http://activiti.org/community.html

The Activiti Explorer contains its own Activiti Process Engine instance. Activiti Explorer包含其自己的Activiti Process Engine实例。 Your application would also have its own instance. 您的应用程序还将具有自己的实例。 It is a common approach that both applications share the same database (eg MySQL) 两个应用程序共享同一数据库(例如MySQL)是一种常见的方法

Look at this picture taken from the Book "Activiti in Action": 看这张摘自《 Activiti in Action》一书的照片:

在此处输入图片说明

For the Activiti Java API, look at the Activiti Java Guide: http://activiti.org/javadocs/ 对于Activiti Java API,请查看《 Activiti Java指南》: http : //activiti.org/javadocs/

To start a process, you can use the RuntimeService like this: 要开始一个过程,可以使用RuntimeService如下所示:

ProcessEngine processEngine = ProcessEngineConfiguration.createProcessEngineConfigurationFromResourceDefault()
.buildProcessEngine();

RuntimeService runtimeService = processEngine.getRuntimeService();

ProcessInstance processInstance = 
runtimeService.startProcessInstanceByKey("processId");

Lets assume you defined the first Task as UserTask with kermit as assignee. 假设您将第一个任务定义为UserTask,而kermit为受让人。 After your java code was executed, Kermit can login into the Activiti Explorer and he will see his task. 执行完Java代码后,Kermit可以登录Activiti Explorer,他将看到他的任务。 To achieve this, both applications must share the same database. 为此,两个应用程序必须共享相同的数据库。

The deployment of process-definitions is possible, too. 也可以部署流程定义。 Look at the RepositoryService. 查看RepositoryService。

As very well explained by @Ben the key to interaction with the process engine is usually the decision whether the process engine is bootstrapped in the same process as your application or it is already running inside another web application which has provided REST API (activiti-rest web application) or another web application which may not provide direct REST API but can be used to perform many workflow related tasks through UI (Activiti explorer web application probably does the interaction using direct activiti java API). @Ben很好地解释了与流程引擎交互的关键,通常是决定流程引擎是否在与您的应用程序相同的流程中引导,或者它是否已经在提供REST API的另一个Web应用程序中运行(activiti-rest Web应用程序)或其他可能不提供直接REST API,但可用于通过UI执行许多工作流程相关任务的Web应用程序(Activiti Explorer Web应用程序可能使用直接Activiti Java API进行交互)。 This way Activiti is quite flexible. 这种方式Activiti非常灵活。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM