what is the difference between process variable & global variables?
by gs76pl
hi,
this seems like a basic question i should know the answer to after reading
some documentation but unfortunately after doing some tests with
onExitActions there seems to be some discrepancy between what doc reads and
how the process/action behaves. Could anyone verify my observations:
1. while documentation in "4.4. Data" reads "...Actions can access variables
directly, simply by using the name of the variable as a parameter name" in
fact this is INCORRECT as at that point actions expect a global object to be
in the session!! e.g. below code in onExitAction throws an exception if
tracker obj hasn't been defined as a global variable and entered into the
session (it doesn't matter that the process has tracker variable defined)
tracker.addVisitedNode("dasdf");
2. the only way of accessing process variables is via context object as
below
context.getVariable("tracker")
3. inserting/updating object in the session can be done
a) context.getKnowledgeRuntime().insert("myFact");
b) insert("myFact");
looks like there is no difference here and the second one is simple a
shorter version of doing the same
--
View this message in context: http://drools.46999.n3.nabble.com/what-is-the-difference-between-process-...
Sent from the Drools: User forum mailing list archive at Nabble.com.
15 years
KnowledgeAgent and Guvnor restart
by Gerret Hansper
Hello,
I have got an issue with the KnowledgeAgent that seems not to survive a Guvnor
restart. The scenario is as follows:
* We use Drools 5.0
* On our application server we create a KnowledgeAgent
applying a ChangeSet that points to a package binary on a separate Guvnor server
like so:
SystemEventListenerFactory.setSystemEventListener(new
SystemEventLogger());
ResourceFactory.getResourceChangeNotifierService().start();
ResourceFactory.getResourceChangeScannerService().start();
KnowledgeAgent agent =
KnowledgeAgentFactory.newKnowledgeAgent(workflowName);
agent.applyChangeSet(changeSet);
* Creating the kbase, registering globals and running sessions works fine.
* We shut down Guvnor (or the connection goes down, this was how we spotted the
problem) and restart it after a minute
* We then try to run sessions from the
same agent as above via
kagent.getKnowledgeBase().newStatefulKnowledgeSession();
which returns a ksession, but then setting a global we get
java.lang.RuntimeException: Unexpected global [log]
at
org.drools.common.AbstractWorkingMemory.setGlobal(AbstractWorkingMemory.java:5
50)
at
org.drools.impl.StatefulKnowledgeSessionImpl.setGlobal(StatefulKnowledgeSessio
nImpl.java:284)
>From the debugger I can see that indeed the ruleBase's globals map is empty. The
SystemEventLogger indicates that the KnowledgeAgent unsubscribes from its
resource when Guvnor is down and rebuilds its kbase. Also, it stops scanning the
resource and does not find it once Guvnor is up again. (See log snippet below).
Wouldn't it be better in these cases to keep the resource as is in memory and
try to rescan? I figure that as long as the resource is specified in the
changeSet it should be considered part of the kbase and not be removed if it
cannot be found.
For the time being, does anyone have a suggestion how to avoid these problems?
We could catch the RuntimeException and recreate the KnowledgeAgent, but perhaps
there is a better way?
Thanks, Gerret
-- SystemEventLog --
# Guvnor is up here
07:58:01,881 ResourceChangeScanner attempt to scan 1 resources
07:58:02,209 ResourceChangeScanner thread is waiting for 60
07:58:15,067 ResourceChangeScanner attempt to scan 1 resources
# Guvnor goes down here
07:58:16,738 ResourceChangeScanner removed resource=[UrlResource
path='http://localhost:7080/drools-
guvnor/org.drools.guvnor.Guvnor/package/com.foo.bar/LATEST']
07:58:16,738 ResourceChangeNotification received ChangeSet notification
07:58:16,738 ResourceChangeScanner thread is waiting for 60
07:58:16,738 ResourceChangeNotification processing ChangeSet
07:58:16,738 ResourceChangeNotification ChangeSet removed resource=[UrlResource
path='http://localhost:7080/drools-
guvnor/org.drools.guvnor.Guvnor/package/com.foo.bar/LATEST'] for
listener=org.drools.agent.impl.KnowledgeAgentImpl@1053d6d
07:58:16,738 ResourceChangeNotification ChangeSet removed resource=[UrlResource
path='http://localhost:7080/drools-
guvnor/org.drools.guvnor.Guvnor/package/com.foo.bar/LATEST'] for
listener=org.drools.agent.impl.KnowledgeAgentImpl@b71c17
07:58:16,738 KnowledgeAgent received ChangeSet changed notification
07:58:16,738 KnowledgeAgent received ChangeSet changed notification
07:58:16,738 KnowledgAgent applying ChangeSet
07:58:16,738 ResourceChangeNotification thread is waiting for queue update
07:58:16,738 KnowledgAgent applying ChangeSet
07:58:16,738 KnowledgeAgent unsubscribing from resource=[UrlResource
path='http://localhost:7080/drools-
guvnor/org.drools.guvnor.Guvnor/package/com.foo.bar/LATEST']
07:58:16,738 ResourceChangeNotification unsubscribing
listener=org.drools.agent.impl.KnowledgeAgentImpl@1053d6d to
resource=[UrlResource path='http://localhost:7080/drools-
guvnor/org.drools.guvnor.Guvnor/package/com.foo.bar/LATEST']
07:58:16,738 KnowledgeAgent rebuilding KnowledgeBase using ChangeSet
07:58:16,738 KnowledgeAgent unsubscribing from resource=[UrlResource
path='http://localhost:7080/drools-
guvnor/org.drools.guvnor.Guvnor/package/com.foo.bar/LATEST']
07:58:16,738 ResourceChangeNotification unsubscribing
listener=org.drools.agent.impl.KnowledgeAgentImpl@b71c17 to
resource=[UrlResource path='http://localhost:7080/drools-
guvnor/org.drools.guvnor.Guvnor/package/com.foo.bar/LATEST']
07:58:16,738
KnowledgeAgent rebuilding KnowledgeBase using ChangeSet
07:58:16,738 KnowledgeAgent new KnowledgeBase now built and in use
07:58:16,738 KnowledgeAgent new KnowledgeBase now built and in use
07:59:02,202 ResourceChangeScanner attempt to scan 0 resources
07:59:02,202 ResourceChangeScanner thread is waiting for 60
# Guvnor back up here
07:59:16,731 ResourceChangeScanner attempt to scan 0 resources
07:59:16,731 ResourceChangeScanner thread is waiting for 60
--
Nur noch bis 31.01.2010: DSL-Komplettpaket für 16,99 Euro/mtl.!*
http://portal.gmx.net/de/go/dsl02
15 years
Drools & jBPM Workshops (May 2011) - New York and Washington DC
by Mark Proctor
http://blog.athico.com/2011/04/drools-jbpm-workshops-may-new-york-and.html
After JBoss World we have two Drools and jBPM5 workshops in May for New
York and Washington. These are free events open to all in the public:
The events will be a mixture of talks with lots of time for questions
and discussions.
Speakers:
Mark Proctor - Drools co-creator and Project Lead
Kris Verlaenen - jBPM Project Lead
Edson Terelli - Drools technical lead.
Event: New York- Registration page and agenda
<http://www.jboss.org/events/workshops/drools.html>*
Date: *Tuesday, May 10, 2011
*Time*: 8:30am -- 5:30pm (breakfast, lunch, afternoon snack provided)
*Cost*: Free but register as seats are very limited.
*Location*: Affinia Manhattan Hotel
371 Seventh Avenue,
New York, NY 10001
Event: Washington -Registration page and agenda
<http://www.carahsoft.com/event-detail/846/redhat/>*
Date: *Thursday, May 12, 2011
*Time*: 8:30am -- 4:00pm
*Cost*: Free but register as seats are very limited.
*Location*: Renaissance Washington
999 Ninth Street, NW
Washington, DC 2000
15 years
Rules with C++
by Sumeet Karawal
Hi All,
I have my application written in C++. How can I use Drools to make rules
that work on C++ facts. Also How to use BRMS in this case?
It would be very helpful if somebody could guide me on this.
Thanks and Regards,
Sumeet Karawal
Mailto: sumeet.karawal(a)tcs.com
=====-----=====-----=====
Notice: The information contained in this e-mail
message and/or attachments to it may contain
confidential or privileged information. If you are
not the intended recipient, any dissemination, use,
review, distribution, printing or copying of the
information contained in this e-mail message
and/or attachments to it are strictly prohibited. If
you have received this communication in error,
please notify us by reply e-mail or telephone and
immediately and permanently delete the message
and any attachments. Thank you
15 years
help! rule"rule_key" failed to predicate
by 赵慧
hi,thank you very much for helping me with the problem.nevertheless,I have got another error. I compile the program and get the errors as follows:
[4,0]: [ERR 103] Line 4:0 rule 'rule_key' failed predicate: {(validateIdentifierKey(DroolsSoftKeywords.RULE))}? in rule
[4,9]: [ERR 101] Line 4:9 no viable alternative at input 'com' in rule package
I don't know how it happened, looking forward to your reply! thank you !!!
> Try adding 'dialect "mvel"' (no single quotes) after the rule name to the top of each of the rules. I have seen this error before and doing this resolved the issue.
>
> >hello,everyone!I wrote a rule with Drools,but the error told me that the field Server.Message is not visible, I can't find how it happens. Please
> >help me, I am almost exhausted with it. thank you.
> >the rules are as follows:
> >
> >package com.sample
> >import com.sample.Server;
> >
> >rule "system will execute 'tc' command"
> > when
> > eval(Server.Message>8388608)
> > then
> > System.out.println("The network is so crowd that it needs repairing.");
> > Runtime.getRuntime().exec("tc");#execute the "tc" command end
> >
> >rule "caution"
> > when
> > eval(Server.Message==8388608)
> > then
> > System.out.println("caution!The network maybe will get blocked very soon."); end
> >
> >rule "fluent network"
> > when
> > eval(Server.Message<8388608)#conditions
> > then
> > System.out.println("the current network is very good");
> > #actions
> >end
>
>
> _______________________________________________
> rules-users mailing list
> rules-users(a)lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>
15 years
Calling a method with varargs
by janders
Hey all, I've got a rule in a DRL file that I'm trying to call an object
method that contains a varargs parameter.
The method signature looks like so:
public void addMessage(int displayPriority, String messageFormat, Object...
messageArgs) {
The rule looks like so:
rule "Notice Quantity"
no-loop
when
$notice : Notice(quantity > 0);
then
$explanation.addMessage(1, "%s Quantity = %,d", $notice.dispositionCode,
$notice.quantity);
end
When I run this rule base, I get this runtime error from the Drools engine:
Caused by: [Error: unable to resolve method:
com.package.TriggerExplanation.addMessage(java.lang.Integer,
java.lang.String, java.lang.String, java.lang.Integer) [arglength=4]]
[Near : {... Unknown ....}]
This feels very much like either the MVEL engine or Drools can't resolve a
method with varargs. I found nothing in any of the documentation and the
only thread on these forums that references varargs was a few years old.
Can anyone tell me if Drools does/does not support method calls with
varargs? Doing this without varargs is going to be a galactic pain in the
butt.
Thanks!
Jason
--
View this message in context: http://drools.46999.n3.nabble.com/Calling-a-method-with-varargs-tp2812191...
Sent from the Drools: User forum mailing list archive at Nabble.com.
15 years
Support for Probabilistic reasoning & FOL
by Arjun Dhar
Hi,
though it is clear Rule Engine (lke Drools) supports Declarative
programming and First order Logic or FOL (with existential quantifiers and
works) .... am also looking for Probabilistic Reasoning.
Example:
Fact: A U B => C; this fact exists with a probability of 0.9.
Principles namely being: Locality, Detachment, Truth functionality (i.e.
when predicates in facts are not mutually exclusive then probabilistic
calculations are not as simple as Boolean operations) etc.
Has such theory been worked into Drools yet or are there any plans for the
future?
I'd assume the same concepts can be used on Fuzzy rules and fuzzy sets.
Am sure these are practical issues that at some point the Drools team would
have thought about. Whats the direction on this?
thanks
--
View this message in context: http://drools.46999.n3.nabble.com/Support-for-Probabilistic-reasoning-FOL...
Sent from the Drools: User forum mailing list archive at Nabble.com.
15 years
completing persisted workItem doesn't complete a process
by gs76pl
hi,
i've a very simple process with only 4 work items that run async. For steps
WI1 & WI2 i complete each step but when the process reaches WI3 step i
manually kill the whole process and then load it from a database
i.e.
ksession.loadStatefullSess..
Now after i complete WI3 step i can see that the last step i.e. WI4 gets
executed and marked as completed but when i'm checking my process status its
status is still ACTIVE instead of COMPLETED ?
ksession = JPAKnowledgeService.loadStatefulKnowledgeSession(
mySessionId, getKnowledgeBase(), null, getEnvironment());
ProcessInstance processInstance = ksession.getProcessInstance(myProcessId);
//after below line i can see that WI3 & WI4 get completed
ksession.getWorkItemManager().completeWorkItem(workItemIdForWI3, null);
//here the process still remains as ACTIVE ie.1
processInstance.getState() == ProcessInstance.STATE_ACTIVE
what i've seen in the tables is that all tables (i.e. processinstanceinfo,
variableinstanceinfo,workiteminfo) excepts sessionInfo gets cleared after
completing WI3. Why despite completing all work items the process remains
ACTIVE when in fact it should be COMPLETED
--
View this message in context: http://drools.46999.n3.nabble.com/completing-persisted-workItem-doesn-t-c...
Sent from the Drools: User forum mailing list archive at Nabble.com.
15 years
Re: [rules-users] help! the field *** is not visible
by John Peterson
Try adding 'dialect "mvel"' (no single quotes) after the rule name to the top of each of the rules. I have seen this error before and doing this resolved the issue.
>hello,everyone!I wrote a rule with Drools,but the error told me that the field Server.Message is not visible, I can't find how it happens. Please
>help me, I am almost exhausted with it. thank you.
>the rules are as follows:
>
>package com.sample
>import com.sample.Server;
>
>rule "system will execute 'tc' command"
> when
> eval(Server.Message>8388608)
> then
> System.out.println("The network is so crowd that it needs repairing.");
> Runtime.getRuntime().exec("tc");#execute the "tc" command end
>
>rule "caution"
> when
> eval(Server.Message==8388608)
> then
> System.out.println("caution!The network maybe will get blocked very soon."); end
>
>rule "fluent network"
> when
> eval(Server.Message<8388608)#conditions
> then
> System.out.println("the current network is very good");
> #actions
>end
15 years