简体   繁体   English

从Drools Rule执行bpmn文件

[英]Execute bpmn file from Drools Rule

I would like to execute bpmn file which is in another project. 我想执行另一个项目中的bpmn文件。 Could anyone tell me how to do this? 谁能告诉我该怎么做?

I have something like this in my rule, but it's doesn't work: 我的规则中有这样的内容,但这是行不通的:

function performScenario()
{
    KieHelper kHelper = new KieHelper();
    KieBase kBase = kHelper.addResource(ResourceFactory.newFileResource("D:\\jbpm-installer\\workspace\\JbpmTest\\src\\main\\resources\\sample.bpmn")).build();
    KieSession kieSession = kBase.newKieSession();
    kieSession.startProcess("com.sample.bpmn.hello");
}

I have error: Unknown process ID 我有错误:未知的进程ID

What do you mean by the process is in another project? 您所说的过程在另一个项目中是什么意思? You will need to load the project into the same ksession in order to be able to start it from there. 您将需要将项目加载到相同的ksession中,以便能够从那里启动它。 Instead of doing this: 而不是这样做:

kHelper
    .addResource(
        ResourceFactory.newFileResource("D:\\jbpm-installer\\workspace\\JbpmTest\\src\\main\\resources\\sample.bpmn")
    )
    .build();

Just do the same when you build your rules session and then you will be able to do something like 在构建规则会话时只需执行相同的操作,然后您就可以执行类似的操作

kcontext.startProcess(<ID HERE>);

HTH HTH

I think you have an error in kieSession.startProcess("com.sample.bpmn.hello"); 我认为您在kieSession.startProcess("com.sample.bpmn.hello");有错误kieSession.startProcess("com.sample.bpmn.hello"); The kieSession didn't know the id: "com.sample.bpmn.hello" , so it throw an error: Unknown Process ID. kieSession不知道ID: "com.sample.bpmn.hello" ,因此抛出错误:Unknown Process ID。

Open your bpmn file in text or xml editor and look for this line of code: 在文本或xml编辑器中打开bpmn文件,然后查找以下代码行:

    ...
    <process processType="Private" isExecutable="true" id="Sample" name="Sample Process">
    ...

The id="Sample" is the Process ID. id="Sample"是进程ID。 So your code should be like this: kieSession.startProcess("Sample"); 因此,您的代码应如下所示: kieSession.startProcess("Sample");

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

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