0
votes

I execute a business rule from a process on Jbpm, the rule is simple:

 package com.test.flow;

 rule "sample"
    ruleflow-group "test"
    when

    then
        System.out.println("Hello World");
 end

But, I don't no why, this rule execute only once, for instance, I run a new instance of the process and in the jbpm console print "Hello World", but, when I run a second instance of the process doesn print anymore "Hello World", some one can you help me? or tellme why does this happen?

Screen Jbpm console

1
Are you using the same session for all your process instances? What happen if you use individual sessions for each instance? - Esteban Aliverti
Thanks for reply, I dont shure, I am using Java Remote API, and each time make a call, I make a RuntimeEngine engine = RemoteRuntimeEngineFactory.newRestBuilder().addUrl(baseUrl)... to obtain a new KieSession with engine.getKieSession() and start the process, if I do that from jbpm-console web, run a new instance occur the same. - Daniel Alvarez
@EstebanAliverti Thanks very much!!! I found the solution, you are right, the problem was the session, but not in my code, else in the configuration of the project on jbpm, I did configure the "Project Editor" the "Deployment Descriptor" I change the value "Runtime Strategy" It was "SINGLETON" for "PER_REQUEST" or "PER_PROCESS_INSTANCE" and I solved the problem. Thank you very much!!! - Daniel Alvarez

1 Answers

0
votes

For this kind of "hello-world" rule, using ruleflow-group is most likely just causing confusion. Do you control when this group is activated? How? - Omitting this rule attribute is indicated.

A rule with an empty left-hand-side will execute only once in a session (as Esteban pointed out).

If you want a rule that fires once for each inserted fact, use

rule "new fact"
when
    Object()
then
    System.out.println( "new fact inserted" );
end