Hi Eric,
thanks for your reply;
in my script task I insert the facts before the execution of a business rule task but if I
don't fire in such a way the rule engine, the rules are not executed;
when I can use an application code I usually register an Agenda Listener and everything
works!
Thanks,
Giovanni
----- Messaggio originale -----
Da: "Eric D. Schabell" <erics(a)redhat.com>
A: "Giovanni Marigi" <gmarigi(a)redhat.com>
Cc: "jbpm-dev" <jbpm-dev(a)lists.jboss.org>, "sme-brms"
<sme-brms(a)redhat.com>, sme-jbpm(a)redhat.com
Inviato: Martedì, 16 aprile 2013 9:48:56
Oggetto: Re: jbpm and business rule task
Hi,
If you want to do this form the process itself, you then add a script task to insert the
facts into the working memory, with something like this from the customer evaluation
demo:
// Insert Person and Request into our session for the rules to use.
insert(person);
insert(request);
If you are doing this from your application code it can be done like this (unit test
example):
// setup of a Person and Request.
Person underagedEval = getUnderagedCustomer();
Request richEval = getRichCustomer();
ksession.insert(underagedEval);
// Map to be passed to the startProcess.
Map<String, Object> params = new HashMap<String, Object>();
params.put("person", underagedEval);
params.put("request", richEval);
// Start process
WorkflowProcessInstance processInstance = (WorkflowProcessInstance)
ksession.startProcess("org.jbpm.customer-evaluation", params);
ksession.insert(processInstance);
ksession.fireAllRules();
The rule task is pointing to the rules based on RuleFlowGroup and in the process it will
fireAllRules() at this point using the rules associated with the group you give it. If you
have not previously inserted the facts into memory then it will not have anything to feed
the rules.
Hope this helps?
-- erics
On Apr 16, 2013, at 09:38 , Giovanni Marigi <gmarigi(a)redhat.com> wrote:
Hi,
in case I would like to call a process with business rules tasks via jbpm console, where
should I insert the code to fire the rules?
Should I get the ksession from a kcontest and then call the fireAllRules method? (every
time before a rule task?)
I don't have any custom code to start the process where I could use a stateful
session and use one of the two approaches
Fire Until Halt
Agenda & Process Event Listeners
Moreover why when a process meets a rule task doesn't fire automatically the rules?
In my opinion this should be the default behaviour
Thanks,
Giovanni
--
Giovanni Marigi
Red Hat - JBoss Consultant -
email: gmarigi(a)redhat.com
Mobile: +39 3423175986
Office: +39 0687502315
Red Hat Italy
Via Andrea Doria 41m
00192 Roma - Italy
www.redhat.com
Prima di stampare, pensa all'ambiente ** Think about the environment before printing
--
Giovanni Marigi
Red Hat - JBoss Consultant -
email: gmarigi(a)redhat.com
Mobile: +39 3423175986
Office: +39 0687502315
Red Hat Italy
Via Andrea Doria 41m
00192 Roma - Italy
www.redhat.com
Prima di stampare, pensa all'ambiente ** Think about the environment before printing