Re: [rules-users] [rules-dev] DRL - Local objects
by Felipe Piccolini
Adhir,
Im facing the same challenge using rules in a ETL process where
performance is a main concern (some millisecs do the different when you have
millions of executions), so I'm using Globals to keep data in the session.
You can add a global object as a global variable in the session scope and
all
the rules will have access to it in conditions and actions.
MyHelperClass helper = new MyHelperClass();
StatelessKnowledgeSession statelessSession =
kb.newStatelessKnowledgeSession();
if (statelessSession == null){
log.error("Session was not created.");
return;
}
statelessSession.setGlobal("myHelper", helper);
In the DRL you import the class and define the global. You can also define
some static (or not) methods in the helper class to assit you and use them
as functions in your rules (if used as functions, methods needs to be
static, if no static, then they can be used as methods of the global
instance in
the consequence block)
import com.mycompany.rules.helpers.MyHelperClass;
import function
com.mycompany.helpers.MyHelperClass.SOME_FUNCTION;
global com.emycompany.helpers.MyHelperClass helper;
This solution is not ideal, because you relay on java classes (code outside
of the rules and RETE) to perform evaluations (functions with evals in
conditions) and
the consequence hide some code in java classes, which is not so good because
one of the main features of a rule engine is the separation of the logic
from the
static code... but it works and it helps sometimes.
Good luck.
On Wed, Mar 23, 2011 at 7:55 AM, Adhir Mehta <adhirmehta21(a)gmail.com> wrote:
> Thanks for the reply.
>
> I think I was not up to the point. Modifying facts re-executes the rules to
> maintain the truth. In my case, I want to pass the data between the rules
> and also do not want rules to execute again. I know if no-loop option is
> specified, it will not be re-executed however I do not want rule engine to
> even go & check for no-loop option (which is additional work).
>
> I may be wrong as I am new to drools.
>
> Thanks,
> Adhir
>
>
> On Wed, Mar 23, 2011 at 11:48 AM, Mark Proctor <mproctor(a)codehaus.org>wrote:
>
>> On 23/03/2011 05:46, Adhir Mehta wrote:
>>
>> Hi,
>>
>> I have written the rule DRL file having around 30 rules in it. Some of
>> the rules do intermediate calculation and those calculation result is
>> expected in the other rules in same DRL file. I can do this by modifying the
>> facts objects in one rule and get the value in other rule. However,
>> modifying the facts object rebuild the RETE tree and affects the
>> performance. Is there any way by which I can pass the data across the rules
>> in same DRL file without rebuilding the RETE tree. (I am more concerned
>> about the performance)
>>
>> Please continue this conversation on the USER mailing list
>> http://www.jboss.org/drools/lists.html
>>
>> Modifying facts does not rebuild the rete. Adding/Removing rules causes
>> changes to Rete tree.
>>
>>
>> Thanks,
>> Adhir
>>
>>
>> _______________________________________________
>> rules-dev mailing listrules-dev@lists.jboss.orghttps://lists.jboss.org/mailman/listinfo/rules-dev
>>
>>
>>
>> _______________________________________________
>> rules-dev mailing list
>> rules-dev(a)lists.jboss.org
>> https://lists.jboss.org/mailman/listinfo/rules-dev
>>
>>
>
> _______________________________________________
> rules-dev mailing list
> rules-dev(a)lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-dev
>
>
--
-----------------------------
Felipe Piccolini
felipe.piccolini(a)gmail.com
14 years, 9 months
Problem with "multiple instances" component
by HMandic
Hi all,
I'm stuck on a problem on using multiple instances with reusable
sub-process.
I have a simple sub-process that needs to be run for list.size() times
(where list is a "CollectionExpression" property) inside the "Multiple
Instances" component in a parent process.
But the parent process always just skips these sub-procesess and ends
without error (the list is not empty).
I think it has something to do with me being unable to insert values in
"StartNodeId" and "EndNodeId" properties, the editor (inside Eclipse) just
deletes those fields upon saving. It worked before with .rf flows, but it
doesn't now when I'm using .bpmn.
Also, the documentation (jbpm-5.1-SNAPSHOT docs) doesn't even mention
"StartNodeId" and "EndNodeId" properties for multiple instances component
although they are there in the editor.
Anybody had the same problem?
I'm using Drools 5.2.0M1 and jbpm5.1.
--
View this message in context: http://drools-java-rules-engine.46999.n3.nabble.com/Problem-with-multiple...
Sent from the Drools - User mailing list archive at Nabble.com.
14 years, 9 months
Eclipse Based Rule IDE
by Suk Fung
All,
Does anyone know if we can view a list of rule file changes in Eclipse IDE so we
know which files need to be updated in the workspace?
Thanks for any information in advance.
Suk
14 years, 9 months
how to write the rule
by yong zhao
Hi,
public class Order {
Buyer buyer;
List<Item>orderItems = new ArrayList<Item>();
public List<Item> getOrderItems() {
return orderItems;
}
public void setOrderItems(List<Item> items) {
this.orderItems = items;
}
}
public class Item {
String id;
double price;
int amount;
String catelogTag;
public double getPrice() {
return price;
}
public void setPrice(double price) {
this.price = price;
}
}
business rule
import base.Order;
import base.Item;
rule "rule1"
when
$o: Order($b : buyer);
eval ($b != null && $b.getUserLevel() == UserTag.TAG[UserTag.TA]);
then
System.out.println("");
end
rule "rule2"
when
$o:Order($b : buyer);
#here is the error message in eclipse: "Item could not be resolved"
$i:Item() from $o.orderItems;
then
System.out.println("");
end
when I try to build the rule and run case, I got the following error in
Rule Compilation error : [Rule name='rule2']
Rule_rule2_0.java (8:785) : item cannot be resolved
1. What is my error in the code and how to get that every Item in the orderItems
list?
2. Another question is how to get source code when build the rule via eclise
plugin?
thinks in advance
14 years, 9 months
Re: [rules-users] Can we point to db repository url directly in ChangeSet.xml
by Michael Anstis
Hi Sathya,
This is by design.
Any consumer of the "Guvnor service" will need to provide authentication
parameters in the HTTP request.
This sounds like it could be an issue with ESB, perhaps you can pose a
question to their support forums asking how you can include authorisation
credentials in their configuration?
Please direct your emails to the drools-user mailing list as any information
could be of value to others in the future.
If I've mis-understood something please let me know :)
With kind regards,
Mike
On 22 March 2011 22:00, Sathya Prakash <prakashagarval(a)gmail.com> wrote:
> Hi Mike,
>
> If Drools guvnor is password protected then package url can not be accessed
> directly.
>
> In esb we can specific url or dir location. I have specified url i need to
> pass credentials. as of now its throwing 401 hhtp code.
>
> regards,
> sathya prakash
>
> On Wed, Mar 23, 2011 at 1:55 AM, Michael Anstis <michael.anstis(a)gmail.com>wrote:
>
>> I'm not familiar with JBoss ESB Drools integration.
>>
>> However, AFAIK, the file is not password protected but the (Guvnor
>> hosting) web-server authenticates HTTP requests to "close" access.
>>
>> Can you please explain more what you mean by restricting access to a
>> particular server?
>>
>> Thanks,
>>
>> Mike
>>
>>
>> On 22 March 2011 21:39, Sathya Prakash <prakashagarval(a)gmail.com> wrote:
>>
>>> Hi,
>>>
>>> If package file is password protected, then how to restrict to particular
>>> server. I am using JBOSS ESB drools integration.
>>>
>>>
>>>
>>> Regards,
>>> Sathya Prakash.
>>>
>>> 2011/3/23 Michael Anstis <michael.anstis(a)gmail.com>
>>>
>>>> The repository used by Guvnor is not a database but an implementation of
>>>> JCR (Content Repository for Java Technology).
>>>>
>>>> We currently support Apache Jackrabbit and IIRC JBoss Modeshape from
>>>> 5.2.0.M1 as an option (if not in an earlier version). Whilst it is possible
>>>> to configure either of these JCR implementations to persist to a RDBMS
>>>> instead of a FileSystem, I believe the table content is a (proprietary)
>>>> binary form at not easily integrated. Consequentially we only expose the
>>>> facility to download rule packages through the channels you state.
>>>>
>>>> With kind regards,
>>>>
>>>> Mike
>>>>
>>>> 2011/3/22 Suk Fung <suk_f(a)yahoo.com>
>>>>
>>>>> All,
>>>>> To consume the rules in the application, we can either use package URI
>>>>> or download a binary .pkg file from guvnor. I just wonder if the
>>>>> application can connect to the database repository directly?
>>>>>
>>>>> Thanks for any information in advance.
>>>>>
>>>>> Suk
>>>>>
>>>>>
>>>>> _______________________________________________
>>>>> 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
>>>>
>>>>
>>>
>>>
>>> --
>>> Cheers,
>>> Sathya Prakash.
>>> *సత్య ప్రకాష్*.
>>>
>>>
>>
>
>
> --
> Cheers,
> Sathya Prakash.
> *సత్య ప్రకాష్*.
>
>
14 years, 9 months
Can we point to db repository url directly in ChangeSet.xml
by Suk Fung
All,
To consume the rules in the application, we can either use package URI or
download a binary .pkg file from guvnor. I just wonder if the application can
connect to the database repository directly?
Thanks for any information in advance.
Suk
14 years, 9 months
problem loading and updating process definitions
by Wen Yao
Hello,
I followed the procedure in this post:
http://community.jboss.org/people/bpmn2user/blog/2011/02/21/jbpm5-example...
It mentioned two ways to deploy a process definition: (1) using Eclipse
plugin to add the process and artifacts to Guvnor and then build the
package; (2) put the jar and bpmn into their according directory, and then
restart the jboss server.
In my practice, my bpm console sometimes loads the process definitions from
Guvnor and sometimes from the bpmn directory. The processes in these two
repository/locations are different. Can I take control of this situation?
The performance is always not stable.
I also have some problem updating a process. When I modify a process schema
and update the bpmn file in the -Djbpm.console.directory. The BPM console
just stick to the old version. I have restarted the jboss server after the
update.
Thank you!
Best regards,
----
Wen
14 years, 9 months
Release Status
by Mark Proctor
We are still trying to integrate the new parser. We now hope that the
main parser integration will be done tomorrow. However that still needs
to be made to work in Eclipse. So the build probably won't be blue until
this coming monday - a week later than expected. That means that M2
probably won't be done now until end of next week. Which will push back
the intended release date to the early part of mid April.
If anyone can help on the eclipse integration of the parser, do pop on
to irc and offer a hand :)
http://www.jboss.org/drools/irc.html
Mark
14 years, 9 months
Agenda Groups and Salience
by Dean Whisnant
Hello,
Are there any conflicts in 5.1 between using salience and agenda groups?
I have three sets of rules 1) base software, 2) Trading Partner Specific, 3) Customer Specific.
These three sets are split into different Guvnor packages and all of #1 have an agenda group of "base", all of #2 have an agenda group of "tradingpartner" and all of #3 have no agenda group assigned.
We load all the rules to the knowledge session, letting it know to fire them in that order.
In my #1 set I have a few hundred rules. About 10 of those rules it matters what individual order they fire in so I was setting up salience for them as well.
Rule #1 has a salience of 21000 and it's job is to see if this is the first line item of a claim and if so to instantiate a new object, hasCOB.
Rule #2 has a salience of 20900 and checks to see if the incoming claim is medicare and if so, sets a Boolean, hasMedicare, to true and then does some output so I know if it set it
Rule #3 has a salience of 20900 and checks to see if the incoming claim is other insurance and if so, sets a Boolean, hasOther, to true and then does some output so i know if it set it
Rule #4 has a salience of 20800 and looks to see if there is a hasCOB object with hasMedicare = to true and then does output so I know if it worked
Rule #5 has a salience of 20800 and looks to see if there is a hasCOB object with hasOther = to true and then does output so I know if it worked
So I run a sample file through that hasCOB and should set hasOther to true.
Rule #1 fires and creates hasCOB
Rule #3 fires and sets hasOther to true and gives me output
Rule #5 doesn't fire???
Whether or not salience is the best method to accomplish this, shouldn't this work? DO you see a better way to accomplish this? Rules 4 and 5 are dummy rules here for testing, but what comes next is calculations based upon the existence of hasOther and/or hasMedicare.
I'm at a loss here and any thoughts/help would be welcomed...
Thank you!
Dean
14 years, 9 months