Drools Guvnor Remoting API
by Steve Ronderos
Hello Again,
I asked a question similar to this awhile back, David Sinclair answered
some of my questions, but I'm still looking for a few features.
Here is my use case.
We are deploying Guvnor to an enterprise environment.
We plan on having one Guvnor for our rule authors to create/edit rules in.
We plan on using selectors to control which rules are included into
packages that are built for different environments (development, test,
production).
We can't have our application that use rules pointing directly at the
Guvnor instance.
We want an automated "deployment" process.
Here is what I was thinking.
I would like to be able to invoke a build, using a specified selector,
then create a snapshot that follows a specific naming convention (ie with
the selector's name in the snapshot name), in sequence. In order to do
this, I would like to, from a remote application, tell Guvnor to do a
build, then to do a snapshot. So essentially what I'm asking for is a
remoting API for Guvnor's features. I've looked through some of the
Guvnor code and I believe I see that there is a remote API for the
drools-repository that Guvnor sits on, but what I need is specifically
Guvnor's features to be made available in a remoting API.
Does anyone know if such a thing exists? If not is it planned? If not, am
I even asking for a desirable feature?
Thanks,
Steve Ronderos
15 years, 4 months
Re: [rules-users] Drools fusion query
by Justin King
Hi,
>
> My names Justin King, I'm a part of a research project at Swinburne
> University of Technology in Melbourne, Australia. my question is in regards
> to the new Drools and more specifically fusion. I'm having trouble
> determining whether Fusion might fulfill a requirement of our project so
> maybe you can help me out. Essentially we are in need of an Event Condition
> Action (ECA) engine. We wish to be able to define trigger the firings of
> certain rules based on an event occurring inside our system, e.g. a timer
> going off. Any sets of rules listening for this event should evaluate their
> 'when' conditions and execute their 'then' actions. So essentially its
> something like:
>
> Event: Timer expires
> Rule: rule 1
>
> Event Timer expires
> Rule: rule 3
>
> So rule 1 and 3 have now 'subscribed' to the timer event. so rule 1 might
> be something like
>
> CONDITION 'if students have not finished their exam'
> ACTION 'fail students'
>
> Does drools fusion allow for this type of ECA pattern, or is it a different
> form on engine.
>
> Thanks very much,
>
> Justin King
> Faculty of I.C.T.
> Swinburne University of Technology, Melbourne, Australia
>
>
15 years, 4 months
Re: [rules-users] Question on eval block
by Shah, Malay
Minor correction in the rule:
The eval block is:
eval(lastCapacity == null && entityOid == parentOid && msgType == "8")
instead of
eval(lastCapacity != null && entityOid == parentOid && msgType == "8")
Any help is much appreciated.
Thanks
Malay Shah
________________________________
From: Shah, Malay (IDEAS)
Sent: Monday, August 03, 2009 4:18 PM
To: rules-users(a)lists.jboss.org
Subject: Question on eval block
Hi,
I am trying to use eval block in one of the rules and am a bit confused
about it. The rule is something like this:
rule "LastCapacity"
when
e: Execution(lastCapacity:lastCapacity,parentOid:parentOid)
eo:
ExecutionOrder(entityOid:entityOid,msgType:msgType,execType:execType)
eval(lastCapacity != null && entityOid == parentOid && msgType ==
"8")
then
..................
end
where Execution and ExecutionOrder are 2 objects that are linked by an
ID. I expect eval to return true for certain sets of objects that I
send. But, the above rule exits without running the consequence. On the
other hand, when I write the rule as:
rule "LastCapacity"
when
e: Execution(lastCapacity:lastCapacity==null,parentOid:parentOid)
eo: ExecutionOrder(entityOid:entityOid == parentOid, msgType == "8")
then
.............................
end
the rule triggers the consequence for same set of objects. I thought
that if the expression in eval block comes out to be true, the
consequence will be triggered. Am I missing something obvious here?
Thanks
Malay Shah
--------------------------------------------------------------------------
NOTICE: If received in error, please destroy, and notify sender. Sender does not intend to waive confidentiality or privilege. Use of this email is prohibited when received in error. We may monitor and store emails to the extent permitted by applicable law.
15 years, 4 months
Question on eval block
by Shah, Malay
Hi,
I am trying to use eval block in one of the rules and am a bit confused
about it. The rule is something like this:
rule "LastCapacity"
when
e: Execution(lastCapacity:lastCapacity,parentOid:parentOid)
eo:
ExecutionOrder(entityOid:entityOid,msgType:msgType,execType:execType)
eval(lastCapacity != null && entityOid == parentOid && msgType ==
"8")
then
..................
end
where Execution and ExecutionOrder are 2 objects that are linked by an
ID. I expect eval to return true for certain sets of objects that I
send. But, the above rule exits without running the consequence. On the
other hand, when I write the rule as:
rule "LastCapacity"
when
e: Execution(lastCapacity:lastCapacity==null,parentOid:parentOid)
eo: ExecutionOrder(entityOid:entityOid == parentOid, msgType == "8")
then
.............................
end
the rule triggers the consequence for same set of objects. I thought
that if the expression in eval block comes out to be true, the
consequence will be triggered. Am I missing something obvious here?
Thanks
Malay Shah
--------------------------------------------------------------------------
NOTICE: If received in error, please destroy, and notify sender. Sender does not intend to waive confidentiality or privilege. Use of this email is prohibited when received in error. We may monitor and store emails to the extent permitted by applicable law.
15 years, 4 months
Error unmarshalling KnowledgeBase
by nestabur
Hi all,
I'm getting 2 different errors trying to unmarshalling 2 different KBases:
1: org.drools.RuntimeDroolsException: unable to determine operator for
symbol [after]
2: java.io.StreamCorruptedException: invalid stream header: 776CACED
The 1st one seems to be caused when using the operator after in the DRL, so
the marshalling/unmarshalling strategies dont support CEP rules?
The 2nd one could be caused because of using different marshallers ... but I
use the same!!
My marshalling methods are:
public void save(FileOutputStream out) throws IOException{
DroolsObjectOutputStream droolsOut = new
DroolsObjectOutputStream(out);
droolsOut.writeObject(ksession.getKnowledgeBase());
Marshaller mas =
createMarshaller(ksession.getKnowledgeBase());
mas.marshall(droolsOut, ksession);
}
public void load(FileInputStream input) throws IOException,
ClassNotFoundException{
DroolsObjectInputStream droolsIn = new
DroolsObjectInputStream(input);
KnowledgeBase kbase = (KnowledgeBase)droolsIn.readObject();
Marshaller mas = createMarshaller(kbase);
ksession = mas.unmarshall(input);
}
private Marshaller createMarshaller(KnowledgeBase kbase){
ObjectMarshallingStrategyAcceptor acceptor =
MarshallerFactory.newClassFilterAcceptor(new String[]{"*.*"});
ObjectMarshallingStrategy strategy =
MarshallerFactory.newSerializeMarshallingStrategy(acceptor);
return MarshallerFactory.newMarshaller(kbase,new
ObjectMarshallingStrategy[]{strategy});
}
--
View this message in context: http://www.nabble.com/Error-unmarshalling-KnowledgeBase-tp24788799p247887...
Sent from the drools - user mailing list archive at Nabble.com.
15 years, 4 months
can functions be used in rule's when part?
by Abarna Ramachandran
I really appreciate your help. I understand my mistake. I have another
question. Can i use a fact as a parameter for function defined in the rule
and make a call to that function in the when part of the rule.
For example something like this
rule CheckStationNumber
when
AssertionObject(getRecord(AssertionObject).getStationNo() == null)
then
error("station number should not be null",log);
end
thanks
Abarna
2009/8/1 Wolfgang Laun <wolfgang.laun(a)gmail.com>
> The global ao must be assigned to the ksession, from your Java code, by
> calling
> ksession.setGlobal( "ao", assertionObject )
> before you do anything that triggers LHS evaluations. See Drools Expert,
> section 4.5.2.
>
> The WM and rule setup as you present it does not make sense (to me). If you
> insert an AssertionObject as a WM fact, you shouldn't have it as a global.
> If you want it as a fact, you'll need rules with patterns like
> when
> AssertionObject(...)
> And the same goes for BillingRecord
>
> -W
>
>
> 2009/8/1 Abarna Ramachandran <rabarna(a)archstone.in>
>
>> I am getting the following error when trying to insert my object into
>> ksession. I have attached my rules and java object. Please help me in
>> debugging why this is happening. I am using java 5 and drools 5.0
>>
>> thanks
>>
>> *error while inserting:*
>>
>> org.drools.RuntimeDroolsException:
>> defaultpkg.Rule_CheckStationNumber_0Eval0Invoker@e4aea391 :
>> java.lang.NullPointerException
>>
>> *rules.drl*
>> import java.lang.*;
>> import java.util.*;
>> import ct.fw.rules.*;
>> import ct.fw.utils.*;
>> import ct.fw.rules.*;
>> import ct.fw.logging.*;
>> import ct.fw.pf.dbi.*;
>> import ct.fw.pf.dao.*;
>> import ct.fw.pf.seq.*;
>> import ct.fw.pf.util.*;
>> import ct.fw.pf.vo.*;
>> import ct.fw.ex.*;
>> import org.apache.commons.lang.*;
>> import com.aa.gccp.domain.*;
>>
>> global ct.fw.rules.AssertionObject ao
>> global ct.fw.logging.SmartLogger log
>>
>> function BillingRecord getRecord(AssertionObject ao)
>> {
>> return (BillingRecord) ao.get(0);
>> }
>> function void debug(String msg,SmartLogger log)
>> {
>> log.debug(BusinessRulesValidator.class, msg);
>> }
>> function void error(String msg,SmartLogger log)
>> {
>> log.error(BusinessRulesValidator.class, msg);
>> System.out.println("Message from rules "+msg);
>> }
>>
>> rule CheckTrue
>> when
>> eval(true)
>> then
>> System.out.println("evaluating true");
>> end
>>
>> rule CheckTrue2
>> when
>> eval(true)
>> then
>> error("evaluating from rules2",log);
>> end
>>
>> rule CheckStationNumber
>> when
>> eval(((getRecord(ao)).getStationNo()) == null)
>> then
>> error("station number should not be null",log);
>> end
>>
>> *part where i load the rules and insert the facts. There is no error when
>> loading the rules.drl. That means no parsing errors. The error happens at
>> ksessio.insert(assertionObject).*
>>
>> public void assertRulesObject(AssertionObject assertionObject) throws
>> BusinessRuleException
>> {
>> long current = System.currentTimeMillis();
>> KnowledgeBase kbase = knowledgeBasesMap.get(rulesFileName);
>>
>> if (kbase == null)
>> {
>> kbase = knowledgeBasesMap.get(rulesFileName + DRL);
>> }
>>
>> if ((kbase == null) || ((current - lastRefreshedMilliseconds) >
>> refreshTimeMilliseconds))
>> {
>> if (rulesFileName.toLowerCase().indexOf(DRL) == -1)
>> {
>> kbase = load(rulesFileName + DRL);
>> }
>> else
>> {
>> kbase = load(rulesFileName);
>> }
>>
>> lastRefreshedMilliseconds = System.currentTimeMillis();
>> }
>> this.assertionObject = assertionObject;
>>
>> List assertionobjectslist = new ArrayList();
>> *// i am just doing this part just to make sure assertion object is not
>> null and i will get some answer. this part runs fine. *
>> if (assertionObject != null)
>> {
>> assertionobjectslist = assertionObject.getValidationObjects();
>> String StationNumber = ((BillingRecord)
>> assertionObject.get(0)).getStationNo();
>> System.out.println("Station Number in assertion object is " +
>> StationNumber);
>> }
>> else
>> {
>> System.out.println("Assertion Object is null");
>> }
>> System.out.println("The number of objects in assertionobject is "
>> + assertionobjectslist.size());
>>
>> try
>> {
>> StatefulKnowledgeSession ksession =
>> kbase.newStatefulKnowledgeSession();
>> *//the next line throws the exception*
>> ksession.insert(assertionObject);
>>
>> ksession.fireAllRules();
>> ksession.dispose();
>>
>> }
>> catch (RuntimeDroolsException e1)
>> {
>> throw new BusinessRuleException(e1.getMessage());
>> }
>>
>> businessRulesErrors = assertionObject.getBusinessRulesErrors();
>>
>> if (throwException)
>> {
>> if (!assertionObject.getBusinessRulesErrors().isEmpty())
>> {
>> throw new BusinessRuleException(businessRulesErrors);
>> }
>> }
>> }
>>
>>
>> Any help is appreciated. thanks
>>
>>
>> _______________________________________________
>> rules-users mailing list
>> rules-users(a)lists.jboss.org
>> https://lists.jboss.org/mailman/listinfo/rules-users
>>
>>
>
> _______________________________________________
> rules-users mailing list
> rules-users(a)lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>
>
15 years, 4 months
org.drools.RuntimeDroolsException when inserting into Knowledge Session
by Abarna Ramachandran
I am getting the following error when trying to insert my object into
ksession. I have attached my rules and java object. Please help me in
debugging why this is happening. I am using java 5 and drools 5.0
thanks
*error while inserting:*
org.drools.RuntimeDroolsException:
defaultpkg.Rule_CheckStationNumber_0Eval0Invoker@e4aea391 :
java.lang.NullPointerException
*rules.drl*
import java.lang.*;
import java.util.*;
import ct.fw.rules.*;
import ct.fw.utils.*;
import ct.fw.rules.*;
import ct.fw.logging.*;
import ct.fw.pf.dbi.*;
import ct.fw.pf.dao.*;
import ct.fw.pf.seq.*;
import ct.fw.pf.util.*;
import ct.fw.pf.vo.*;
import ct.fw.ex.*;
import org.apache.commons.lang.*;
import com.aa.gccp.domain.*;
global ct.fw.rules.AssertionObject ao
global ct.fw.logging.SmartLogger log
function BillingRecord getRecord(AssertionObject ao)
{
return (BillingRecord) ao.get(0);
}
function void debug(String msg,SmartLogger log)
{
log.debug(BusinessRulesValidator.class, msg);
}
function void error(String msg,SmartLogger log)
{
log.error(BusinessRulesValidator.class, msg);
System.out.println("Message from rules "+msg);
}
rule CheckTrue
when
eval(true)
then
System.out.println("evaluating true");
end
rule CheckTrue2
when
eval(true)
then
error("evaluating from rules2",log);
end
rule CheckStationNumber
when
eval(((getRecord(ao)).getStationNo()) == null)
then
error("station number should not be null",log);
end
*part where i load the rules and insert the facts. There is no error when
loading the rules.drl. That means no parsing errors. The error happens at
ksessio.insert(assertionObject).*
public void assertRulesObject(AssertionObject assertionObject) throws
BusinessRuleException
{
long current = System.currentTimeMillis();
KnowledgeBase kbase = knowledgeBasesMap.get(rulesFileName);
if (kbase == null)
{
kbase = knowledgeBasesMap.get(rulesFileName + DRL);
}
if ((kbase == null) || ((current - lastRefreshedMilliseconds) >
refreshTimeMilliseconds))
{
if (rulesFileName.toLowerCase().indexOf(DRL) == -1)
{
kbase = load(rulesFileName + DRL);
}
else
{
kbase = load(rulesFileName);
}
lastRefreshedMilliseconds = System.currentTimeMillis();
}
this.assertionObject = assertionObject;
List assertionobjectslist = new ArrayList();
*// i am just doing this part just to make sure assertion object is not null
and i will get some answer. this part runs fine. *
if (assertionObject != null)
{
assertionobjectslist = assertionObject.getValidationObjects();
String StationNumber = ((BillingRecord)
assertionObject.get(0)).getStationNo();
System.out.println("Station Number in assertion object is " +
StationNumber);
}
else
{
System.out.println("Assertion Object is null");
}
System.out.println("The number of objects in assertionobject is " +
assertionobjectslist.size());
try
{
StatefulKnowledgeSession ksession =
kbase.newStatefulKnowledgeSession();
*//the next line throws the exception*
ksession.insert(assertionObject);
ksession.fireAllRules();
ksession.dispose();
}
catch (RuntimeDroolsException e1)
{
throw new BusinessRuleException(e1.getMessage());
}
businessRulesErrors = assertionObject.getBusinessRulesErrors();
if (throwException)
{
if (!assertionObject.getBusinessRulesErrors().isEmpty())
{
throw new BusinessRuleException(businessRulesErrors);
}
}
}
Any help is appreciated. thanks
15 years, 4 months