Re: [rules-users] facing problems while adding a Rule to DROOLS using java client?
KnowledgeBases are not aware of Guvnor, nor are ChangeSets. If you create a new rule and want to add it to Guvnor you'll need to use a suitable API. Please look at Guvnor's documentation, in particular the Integration section and REST API. With kind regards, Mike On 7 March 2012 07:12, PC prakash.3...@gmail.com wrote: Hi, i am using Guvnor-5.2.0 . Through a simple java client class i wanted to add a rule at runtime. below is the snippet of java code i am using to add a rule. KnowledgeBase knowledgeBase = createKnowledgeBase(); session = knowledgeBase.newStatefulKnowledgeSession(); logger = KnowledgeRuntimeLoggerFactory.newFileLogger(session, log/DroolsSample); KnowledgeRuntimeLoggerFactory.newConsoleLogger(session); String ruleDescription = package com.tcube.atyaf.dto;+ import com.tcube.atyaf.dto.EmployeeDataDTO; + rule \SimpleDRLRule\+ @ID(11003588)+ lock-on-active true+ salience -11+ dialect 'mvel'+ when m : EmployeeDataDTO(empName==\PC\);+ then System.out.println( \*rule executed\); + m.setDesignation( \Manager ,Additional Duties Additional hike !!!\ );+ update( m );+ end; byte[] data = ruleDescription.getBytes(); KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder(knowledgeBase); kbuilder.add( ResourceFactory.newClassPathResource(ChangeSet.xml), ResourceType.CHANGE_SET ); kbuilder.add( ResourceFactory.newClassPathResource(TestRule.drl), ResourceType.DRL); kbuilder.add(ResourceFactory.newByteArrayResource(data), ResourceType.DRL); if(kbuilder.hasErrors()) { System.out.println( kbuilder.getErrors() ); return; } CollectionKnowledgePackage kpkgs = kbuilder.getKnowledgePackages(); knowledgeBase.addKnowledgePackages( kpkgs ); emp = new EmployeeDataDTO(); emp.setEmpNo(1); emp.setEmpName(PC); emp.setAge(29); emp.setSalary(new BigDecimal(6500)); session.insert(emp); session.fireAllRules(); I am getting all the rules executed as per exceptation since it is in the same session, however the new rules that i have added are not reflected in Drools-Guvnor UI please help me on code for deploying the knowldgeBase/Package(kpkgs) to Drools-Guvnor UI.. - PC -- View this message in context: http://drools.46999.n3.nabble.com/facing-problems-while-adding-a-Rule-to-DROOLS-using-java-client-tp3806068p3806068.html Sent from the Drools: User forum mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] facing problems while adding a Rule to DROOLS using java client?
Thanks Mike for your quick response. I was trying to add the rule through the REST API using below code, however got status code 405. WebClient client2 = WebClient.create(http://localhost:8080/;); String authorizationHeader = Basic + org.apache.cxf.common.util.Base64Utility.encode(guest:.getBytes()); client2.header(Authorization, authorizationHeader); Response response= client2.path(guvnor-5.2.0.Final-tomcat-6.0/rest/packages/Employee/assets).accept(application/xml).put(ruleDescription.getBytes()); System.out.println(status : +response.getStatus()); whts wrong in this? - PC -- View this message in context: http://drools.46999.n3.nabble.com/facing-problems-while-adding-a-Rule-to-DROOLS-using-java-client-tp3806068p3806290.html Sent from the Drools: User forum mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Drools 5.3 partitioned rule base
I have been reevaluating our use cases and have decided to make a couple modifications: 1.Remove jBPM and Ruleflow groups. While it certainly fit a need I have derived a new way to do the same thing. 2. After reviewing our current ruleset I decided to modify what the rules actually do. At the end of the day the rules are written to infer certain things about the order. With this in mind I have decided to let the rules generate the billing meta-data about the Order(i.e I am may be eligible for charge A and for cap B) and have post processing which will use this information accordingly. The post processing is where the order of the Orders will matter and I am currently thinking of a couple ways to handle this. 3. Partitioning the data by account will allow us to multithread easily when running rules. However rather then have 1 session per account I was thinking about having sessions that represent a group of accounts. 4. With 3 in mind I am now trying to determine the best way to do this. My thinking atm is to create x sessions(for this example let's say 5), each associated with a thread via fireUntilHalt(). Since orders are streamed in by another thread reading from the DB my thinking is this is the most efficient way. However these leads me to a couple questions. How would I determine that an order has been processes through the ruleset and is ready for post processing(with fireAllRules I know that once the rules have fired I can retract the Order and move it to post processing and perhaps this is the answer that will be provided). With fireUntilHalt I thought about raising an event which I would use CDI to listen for and then retract the Order and pass it along for post processing. Is this a good approach? I am open to any suggestion here. 5. After watching a video posted by salaboy(http://vimeo.com/27209589) I am looking into some of the technologies he used. Particularly Kryo. The idea would be that if an Order was eligible for certain post processing it would be serialized to disc with a ranking(i.e key). Another part of the process would then read one at a time and process them in order. Any thoughts around this(I know this is not a drools question but I figured I would put it out there anyway). Thanks Again -Mike laune wrote A few random observations. A recent experiment has shown that insert takes 0.82 seconds for 10 facts with one very simple rule with a CPU G620 @ 2.60GHz and: java version 1.7.0_02 Java(TM) SE Runtime Environment (build 1.7.0_02-b13) Java HotSpot(TM) 64-Bit Server VM (build 22.0-b10, mixed mode) There is, of course, no upper limit for insert as this depends on the number and complexity of the rules. And if you apply the jBPM Process paradigm, I'm not prepared to make any guesses. (It stands to reason that this will incur more overhead than straightforward processing in the Expert engine.) Estimating 1K per order, I'd say that i/o time for 150M orders is not to be neglected. I'd investigate batch (but not bulk) insertion of quantities, so that inserts and fire calls remain in good proportion. Also, balancing i/o threads and processing threads in relation to available CPUs shouldn't be different for an application using Drools. I've been re-reading some of this thread, and the requirement of ordered processing is going to be very difficult if the order this to be maintained over 150M facts. I mentioned dynamic property, but many different salience levels for a large number of activations is not efficient, since this requires a sequential search. -W On 3 March 2012 21:30, gboro54 lt;gboro54@gt; wrote: My previous statement was poorly written(that is what I get for trying to respond via my cell phone ). I agree that the Order fact is simple enough to have a rule retract it once processing is completed. As far as the threading, this is an ejb application being deployed on JBoss 7.1. Because of this I was hoping to use @Asyn and allow the container to really manage the threads. This method would simply request the cached session insert the Order fact, and start the jBPM process to process the Order. Perhaps this part of the design is still flawed as I have only recently been thinking about this and I would welcome all suggestions. Additionally is there any documentation on utilizing drools in a high throughput environment(i.e white papers,etc.) This billing project is the first of many potential projects we are looking to utilize drools for and I would love to share some more documentation on this(as well as read on myself). gboro54 wrote Agreed that I can have a rule to retract the orderi was just thinking if the overhead of a reevaluation but can live with that...As far as the threading...this logic is going to be deployed on a jboss instance using ejb so I was thinking about, using the jboss thread pool...so when I say new thread it may not, be new put, pulled from a pooldoes that
[rules-users] how to invoke java method with variable arguments from drl file
We are upgrading Drools from 5.1 to 5.3, and running into some issue when invoking a Java method with String variable arguments: methodA(String... params) how do we invoke this in a drl file? We used to call it in 5.1 as: objA.methodA({string1}); and it works fine. Now in 5.3, it complains that unable to resolve method using strict-mode: objA.methodA([Ljava.lang.Object;)] If we tried objA.methodA(new String[]{string1}); it complains that unable to resolve method using strict-mode: objA.methodA([Ljava.lang.String;)] It passes the rule loading if we change to : objA.methodA(string1); but when actually running the rule, we are getting error saying unable to resolve method methodA(java.lang.String) -- View this message in context: http://drools.46999.n3.nabble.com/how-to-invoke-java-method-with-variable-arguments-from-drl-file-tp3807314p3807314.html Sent from the Drools: User forum mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] how to invoke java method with variable arguments from drl file
From my experience, if you want call a method from then clause, it has to be static method. Bye bye, Matteo Cusmai Il giorno 07/mar/2012 18:10, womuji cmregis...@gmail.com ha scritto: We are upgrading Drools from 5.1 to 5.3, and running into some issue when invoking a Java method with String variable arguments: methodA(String... params) how do we invoke this in a drl file? We used to call it in 5.1 as: objA.methodA({string1}); and it works fine. Now in 5.3, it complains that unable to resolve method using strict-mode: objA.methodA([Ljava.lang.Object;)] If we tried objA.methodA(new String[]{string1}); it complains that unable to resolve method using strict-mode: objA.methodA([Ljava.lang.String;)] It passes the rule loading if we change to : objA.methodA(string1); but when actually running the rule, we are getting error saying unable to resolve method methodA(java.lang.String) -- View this message in context: http://drools.46999.n3.nabble.com/how-to-invoke-java-method-with-variable-arguments-from-drl-file-tp3807314p3807314.html Sent from the Drools: User forum mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
[rules-users] Simple question about String comparison in Drool
I insert several strings into working memory to make a comparison. But how to compare a anonymous string to another string. code like: List String s = ArrayList String String key function void insertValue( s, KnowledgeHelper kh ) { for( String string : s ) { kh.insert( string ); } } ... When not $string : String( toString() == key) Then Obviously, toString() can not do this task. How to get the string's value ? Cheers. -- View this message in context: http://drools.46999.n3.nabble.com/Simple-question-about-String-comparison-in-Drool-tp3808352p3808352.html Sent from the Drools: User forum mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Simple question about String comparison in Drool
you can just use String( this == key) On Wed, Mar 7, 2012 at 11:32 PM, shawn youngxiao...@hotmail.com wrote: I insert several strings into working memory to make a comparison. But how to compare a anonymous string to another string. code like: List String s = ArrayList String String key function void insertValue( s, KnowledgeHelper kh ) { for( String string : s ) { kh.insert( string ); } } ... When not $string : String( toString() == key) Then Obviously, toString() can not do this task. How to get the string's value ? Cheers. -- View this message in context: http://drools.46999.n3.nabble.com/Simple-question-about-String-comparison-in-Drool-tp3808352p3808352.html Sent from the Drools: User forum mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users -- - MyJourney @ http://salaboy.wordpress.com - Co-Founder @ http://www.jugargentina.org - Co-Founder @ http://www.jbug.com.ar - Salatino Salaboy Mauricio - ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users