[rules-users] Some question about Drools

Esteban Aliverti esteban.aliverti at gmail.com
Wed Mar 30 14:41:27 EDT 2011


Hi Carlos,

1) Can this be done dynamically? I meant, will the workflow change as soon
as I save the new rules on any pre-existing package?
No, you have to re-build the package manually. There is some REST API you
can use if you want to add some degree of automation.

2) Would this allow me to add workflow steps and rules as well as general
data entities?
Not sure what you mean by "workflow steps" here. You can have a mix of
declared and imported (from a jat) entities.

3) What should I have in me interface to be able to use Drools as me rules
engine? I don't get it yet...
Drools is just a framework, so you will need to embed it in your
application. The basic steps are:

//1.- Create a kbuilder
KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();

//2.- Add resources to kbuilder: you could use different Resources and
different ResourceTypes too
kbuilder.add(new FileSystemResource("./event-rules.drl"), ResourceType.DRL);

//3.- Create a kbase
KnowledgeBase kbase = KnowledgeBaseFactory.newKnowledgeBase();

//4.- Add packages from kbuilder to kbase
kbase.addKnowledgePackages(kbuilder.getKnowledgePackages());

//5.- Create a session.
ksession = kbase.newStatefulKnowledgeSession();

//6.- Play with the session
ksession.insert()/update()/fireAllRules() etc.


If you are planning to read the rules from guvnor you can use an URLResource
in step 2.

Best Regards,



XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Esteban Aliverti
- Developer @ http://www.plugtree.com
- Blog @ http://ilesteban.wordpress.com


2011/3/30 Carlos Santiago Moreno <ingcsmoreno at gmail.com>

> Hi everyone, I have been working out with Drools, and a few more doubts
> have appeared.
>
> In Guvnor, each rule is defined inside a package. When you create a new
> rule you must define the package where it belongs. Guvnor doesn't create any
> kbase, you can see a package (in Guvnor) like a DRL file split in  different
> parts: the imports, the globals, each rule, etc. So Guvnor is only in charge
> of maintain different versions of that DRLs.
> 1) Can this be done dynamically? I meant, will the workflow change as soon
> as I save the new rules on any pre-existing package?
>
> If I declare the entities in Guvnor, this will use the "declare" keyword to
> define a New Data Type. Now...
> 2) Would this allow me to add workflow steps and rules as well as general
> data entities?
>
> and, the last one
>
> 3) What should I have in me interface to be able to use Drools as me rules
> engine? I don't get it yet...
>
> And if you can recomend me any web site with information about all this
> things it'll be nice.
>
> Thanks
>
> Carlos S. Moreno
>
> _______________________________________________
> rules-users mailing list
> rules-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-users/attachments/20110330/900bfa6e/attachment.html 


More information about the rules-users mailing list