Re: [rules-users] Problem with Collection

2014-04-11 Thread Wolfgang Laun
If there is no cogent reason for collecting a List and acting on it you
should match a
single Alarm and update it on the rule's right hand side:

rule "Rule [Alarm Collection]"
when
$alarm: Alarm ( justInserted == true )
then
modify( $alarm ){ setJustInserted( false ) }
end

Note that you still can store a reference to this Alarm in some global or
call Java
code for additional processing.

If you do need a collected List, you'll have to copy it on the rule's right
hand side
before you call your Java code.

ArrayList copy = new ArrayList( $alarmColl );

 The update() call is causing instant reorganisation and the collect result
is some
sort of cache.




On 12 April 2014 05:56, mohanm  wrote:

> Hi,
>
> I am using Drools 5.5.0 Final Expert to do Alarm Co-relation. I was trying
> to collect the facts in to the ArrayList collection. My drl file will look
> like below. From the Rule I calling an Java method to access the collected
> facts.
>
> /rule "Rule [Alarm Collection]"
> no-loop
>when
> $alarmColl : ArrayList() from collect(Alarm
>  (
> JustInserted == true;
>  ))
>
> then
> // act on $alarmColl
> end/
>
> while in my Java code I am loop through the collection to set an attribute
> of the Alarm Object. But while I am trying to set this attribute in the
> collection, the collection is getting updated and indexes are changed. Due
> to which all the objects are not updated. Even I tried using the iterator
> to
> access the ArrayList collection. Still the same issue.
>
> /
> while(index < alarmColl.size()){
> Alarm alarmObj=alarmColl.get(index)
>
> if(alarmObj.isJustInserted()) {
> alarmObj.setJustInserted(false);
> theScenario.getSession().update(alarmObj);
> }
> index++;
> }/
>
>
> How can I update the objects in collection without changing the index or
> any
> other way to achieve this.
>
>
>
>
> --
> View this message in context:
> http://drools.46999.n3.nabble.com/Problem-with-Collection-tp4029219.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] Problem with Collection

2014-04-11 Thread mohanm
Hi,

I am using Drools 5.5.0 Final Expert to do Alarm Co-relation. I was trying
to collect the facts in to the ArrayList collection. My drl file will look
like below. From the Rule I calling an Java method to access the collected
facts.

/rule "Rule [Alarm Collection]"
no-loop
   when
$alarmColl : ArrayList() from collect(Alarm 
 ( 
JustInserted == true;
 ))
 
then
// act on $alarmColl
end/

while in my Java code I am loop through the collection to set an attribute
of the Alarm Object. But while I am trying to set this attribute in the
collection, the collection is getting updated and indexes are changed. Due
to which all the objects are not updated. Even I tried using the iterator to
access the ArrayList collection. Still the same issue.

/
while(index < alarmColl.size()){
Alarm alarmObj=alarmColl.get(index)

if(alarmObj.isJustInserted()) {
alarmObj.setJustInserted(false);
theScenario.getSession().update(alarmObj);
}
index++;
}/


How can I update the objects in collection without changing the index or any
other way to achieve this.




--
View this message in context: 
http://drools.46999.n3.nabble.com/Problem-with-Collection-tp4029219.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] KnowledgeAgentImpl registeredResourceMap memory issue

2014-04-11 Thread Davide Sottara
Can you try 5.6.0.Final?
Many issues regarding the KnowledgeAgent were fixed in that version
Thanks
Davide

On 04/11/2014 08:45 PM, Cwen wrote:
>
> 
> View this message in context: Re: KnowledgeAgentImpl
> registeredResourceMap memory issue
> 
> 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] KnowledgeAgentImpl registeredResourceMap memory issue

2014-04-11 Thread Cwen
 



--
View this message in context: 
http://drools.46999.n3.nabble.com/KnowledgeAgentImpl-registeredResourceMap-memory-issue-tp4029216p4029217.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] KnowledgeAgentImpl registeredResourceMap memory issue

2014-04-11 Thread Cwen
We are seeing this HashMap (KnowledgeAgentImpl.registeredResourceMap) keeps
growing when a pkg is updated. It looks like creating more
CompositeClassLoader and not removing the old rule references. So it causes
KnowledgeAgentImpl use large memory. We are using 5.5.0.final.I am attaching
an image from memory analyzer to show how the HashMap holds up multiple
CompositeClassLoader and they are using about 230MB of memory. It increases
when the pkg gets updated with about 150 rules.



--
View this message in context: 
http://drools.46999.n3.nabble.com/KnowledgeAgentImpl-registeredResourceMap-memory-issue-tp4029216.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] Problems deploying war

2014-04-11 Thread Michael Anstis
To answer your remaining questions:

> What is the webapp trying to do with Git? Do I need to point it at some
git repo?

The Workbench tries to clone a demo repository from github.com on startup.
This can be disabled. See
here.
You'll need to set "org.kie.demo" to false.

If you don't have an internet connection to github.com you can use the demo
repositories bundled with the distribution
(kie-wb-example-repositories-6.0.1.Final.zip in the download). You will
need to set "org.kie.example.repositories"

> I tried the jboss instructions here:
http://blog.athico.com/2013/05/how-to-build-and-run-drools-and-guvnor.html

These relate to 5.5 not 6.0. Guvnor used to be the whole web app; now it is
just a small component. See
here
.

On 11 April 2014 15:49, Michael Anstis  wrote:

> Hi,
>
> There have been a few people with Tomcat deployment issues for
> kie-drools-wb, so I thought I'd give it a try.
>
> These are the steps I followed for *successful* deployment (most of which
> is already documented, but not obvious, in the WAR's README.txt file):-
>
> *6.0.1*
>
> Starting with a clean install of Tomcat 7.
>
> 1. Copy "kie-tomcat-integration" JAR into TOMCAT_HOME/lib
> (org.kie:kie-tomcat-integration)
> 2. Copy "JACC" JAR into 
> TOMCAT_HOME/lib(javax.security.jacc:artifactId=javax.security.jacc-api in 
> JBoss Maven
> Repository)
> 3. Copy "slf4j-api" JAR into TOMCAT_HOME/lib(org.slf4j:artifactId=slf4j-api 
> in JBoss Maven Repository)
> 4. Add valve configuration into TOMCAT_HOME/conf/server.xml inside 
> element as last valve definition:
>
>
>
> 5. Edit TOMCAT_HOME/conf/tomcat-users.xml to include roles and users,
> make sure there will be 'analyst' or 'admin' roles defined as it's required
> to be authorized to use kie-wb
> 6. Delete org.uberfire.security.auth.AuthenticationSource inside
> WEB-INF/classes/META-INF/services
> 7. Rename
> org.uberfire.security.auth.AuthenticationSource-TOMCAT-JEE-SECURITY to
> org.uberfire.security.auth.AuthenticationSource inside
> WEB-INF/classes/META-INF/services
> 8. Increase Java's PermGen space by adding file TOMCAT_HOME/bin/setenv.sh
>  containing export JAVA_OPTS="-Xmx1024m -XX:MaxPermSize=256m"
> 9. Start Tomcat with TOMCAT_HOME/bin/startup.sh
> 10. Go to Management Console, http://localhost:8080/management
> 11. Deploy modified WAR
>
> If you do not complete these steps the WAR works "out of the box" but
> you'll need to define Users in WEB-INF/classes/login.config
>
> *6.1.0-SNAPSHOT*
>
> Starting with a clean install of Tomcat 7.
>
> 1. Copy "kie-tomcat-integration" JAR into TOMCAT_HOME/lib
> (org.kie:kie-tomcat-integration)
> 2. Copy "JACC" JAR into TOMCAT_HOME/lib
> (javax.security.jacc:artifactId=javax.security.jacc-api in JBoss Maven
> Repository)
> 3. Copy "slf4j-api" JAR into TOMCAT_HOME/lib
> (org.slf4j:artifactId=slf4j-api in JBoss Maven Repository)
> 4. Add valve configuration into TOMCAT_HOME/conf/server.xml inside Host
> element as last valve definition:
>
>
>
> 5. Edit TOMCAT_HOME/conf/tomcat-users.xml to include roles and users, make
> sure there will be 'analyst' or 'admin' roles defined as it's required to
> be authorized to use kie-wb
> 6. Start Tomcat with TOMCAT_HOME/bin/startup.sh
> 7. Go to Management Console, http://localhost:8080/management
> 8. Deploy modified WAR
>
> With kind regards,
>
> Mike
>
>
>
>
> On 10 April 2014 19:25, Ven Tadipatri  wrote:
>
>>  Hi,
>>   I'm trying to get set up with Drools and Guvnor.  I've had some success
>> building a test program with Drools, but when I saw that there's a webapp
>> to manage and view rules, I was interested in getting that working as
>> well. Unfortunately I haven't had much success with that.
>>   I downloaded the kie-drools-wb-distribution-6.0.1.Final.zip file from
>> the JBoss drools website and dropped the
>> binaries/kie-drools-wb-distribution-wars-6.0.1.Final-tomcat7.0.war
>> into my Tomcat directory.  Tomcat was just hanging for a while, then spit
>> out a bunch of error messages:
>> Apr 10, 2014 2:21:40 PM org.apache.catalina.core.StandardContext
>> startInternal
>> INFO: Deploying web application archive
>> /opt/tomcat/tomcat7/webapps/kie-drools-wb-distribution-wars-6.0.1.Final-tomcat7.0.war
>> Apr 10, 2014 2:21:40 PM org.apache.catalina.core.StandardContext
>> startInternal
>> SEVERE: Error listenerStart
>> Apr 10, 2014 2:21:40 PM org.apache.catalina.core.StandardContext
>> startInternal
>> SEVERE: Context [/kie-drools-wb-distribution-wars-6.0.1.Final-tomcat7.0]
>> startup failed due to previous errors
>> Apr 10, 2014 2:21:40 PM org.apache.catalina.loader.WebappClassLoader
>> clearReferencesThreads
>> SEVERE: The web application
>> [/kie-drools-wb-distribution-wars-6.0.1.Final-tomcat7.0] appears to have
>> started a thread named [pool-4-thread-1] but has failed to stop it. This is
>> very likely to c

Re: [rules-users] How to install Drool web WB - Tomcat?

2014-04-11 Thread Michael Anstis
Please see other email on this subject to which I've replied.


On 11 April 2014 00:13, bbarani  wrote:

> I download the drools workbench war
> (kie-drools-wb-distribution-6.0.1.Final.zip) and tried deploying it on
> Tomcat. The application gets deployed but not getting started (when seen
> from server console).
>
> Do I need to do anything else apart from placing the WAR file in the
> webapps
> directory? please advise
>
>
>
> --
> View this message in context:
> http://drools.46999.n3.nabble.com/How-to-install-Drool-web-WB-Tomcat-tp4029204.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] Guvnor - Importing Drl FIle and its associated model

2014-04-11 Thread Michael Anstis
What version are you using?


On 10 April 2014 20:39, mattmadhavan  wrote:

> Hello,
> In have a working Drools project. I would like to import existing DRL files
> and associated Model file.
>
> I have a custom operator as well. I have packaged the Model and necessary
> operators and util global functions into a jar with their dependencies.
>
> How do I import my DRL and the model jar so that, the DRL's imports 'see'
> the referenced operators and functions and the Model (FACT) classes.
>
> Can some one please let me have the sequence of steps?
>
> Thanks
> Matt
>
>
>
> --
> View this message in context:
> http://drools.46999.n3.nabble.com/Guvnor-Importing-Drl-FIle-and-its-associated-model-tp4029203.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] Problems deploying war

2014-04-11 Thread Michael Anstis
Hi,

There have been a few people with Tomcat deployment issues for
kie-drools-wb, so I thought I'd give it a try.

These are the steps I followed for *successful* deployment (most of which
is already documented, but not obvious, in the WAR's README.txt file):-

*6.0.1*

Starting with a clean install of Tomcat 7.

1. Copy "kie-tomcat-integration" JAR into TOMCAT_HOME/lib
(org.kie:kie-tomcat-integration)
2. Copy "JACC" JAR into
TOMCAT_HOME/lib(javax.security.jacc:artifactId=javax.security.jacc-api
in JBoss Maven
Repository)
3. Copy "slf4j-api" JAR into
TOMCAT_HOME/lib(org.slf4j:artifactId=slf4j-api in JBoss Maven
Repository)
4. Add valve configuration into TOMCAT_HOME/conf/server.xml inside
element as last valve definition:

   

5. Edit TOMCAT_HOME/conf/tomcat-users.xml to include roles and users, make
sure there will be 'analyst' or 'admin' roles defined as it's required to
be authorized to use kie-wb
6. Delete org.uberfire.security.auth.AuthenticationSource inside
WEB-INF/classes/META-INF/services
7. Rename
org.uberfire.security.auth.AuthenticationSource-TOMCAT-JEE-SECURITY to
org.uberfire.security.auth.AuthenticationSource inside
WEB-INF/classes/META-INF/services
8. Increase Java's PermGen space by adding file TOMCAT_HOME/bin/setenv.sh
 containing export JAVA_OPTS="-Xmx1024m -XX:MaxPermSize=256m"
9. Start Tomcat with TOMCAT_HOME/bin/startup.sh
10. Go to Management Console, http://localhost:8080/management
11. Deploy modified WAR

If you do not complete these steps the WAR works "out of the box" but
you'll need to define Users in WEB-INF/classes/login.config

*6.1.0-SNAPSHOT*

Starting with a clean install of Tomcat 7.

1. Copy "kie-tomcat-integration" JAR into TOMCAT_HOME/lib
(org.kie:kie-tomcat-integration)
2. Copy "JACC" JAR into TOMCAT_HOME/lib
(javax.security.jacc:artifactId=javax.security.jacc-api in JBoss Maven
Repository)
3. Copy "slf4j-api" JAR into TOMCAT_HOME/lib
(org.slf4j:artifactId=slf4j-api in JBoss Maven Repository)
4. Add valve configuration into TOMCAT_HOME/conf/server.xml inside Host
element as last valve definition:

   

5. Edit TOMCAT_HOME/conf/tomcat-users.xml to include roles and users, make
sure there will be 'analyst' or 'admin' roles defined as it's required to
be authorized to use kie-wb
6. Start Tomcat with TOMCAT_HOME/bin/startup.sh
7. Go to Management Console, http://localhost:8080/management
8. Deploy modified WAR

With kind regards,

Mike




On 10 April 2014 19:25, Ven Tadipatri  wrote:

>  Hi,
>   I'm trying to get set up with Drools and Guvnor.  I've had some success
> building a test program with Drools, but when I saw that there's a webapp
> to manage and view rules, I was interested in getting that working as
> well. Unfortunately I haven't had much success with that.
>   I downloaded the kie-drools-wb-distribution-6.0.1.Final.zip file from
> the JBoss drools website and dropped the
> binaries/kie-drools-wb-distribution-wars-6.0.1.Final-tomcat7.0.war
> into my Tomcat directory.  Tomcat was just hanging for a while, then spit
> out a bunch of error messages:
> Apr 10, 2014 2:21:40 PM org.apache.catalina.core.StandardContext
> startInternal
> INFO: Deploying web application archive
> /opt/tomcat/tomcat7/webapps/kie-drools-wb-distribution-wars-6.0.1.Final-tomcat7.0.war
> Apr 10, 2014 2:21:40 PM org.apache.catalina.core.StandardContext
> startInternal
> SEVERE: Error listenerStart
> Apr 10, 2014 2:21:40 PM org.apache.catalina.core.StandardContext
> startInternal
> SEVERE: Context [/kie-drools-wb-distribution-wars-6.0.1.Final-tomcat7.0]
> startup failed due to previous errors
> Apr 10, 2014 2:21:40 PM org.apache.catalina.loader.WebappClassLoader
> clearReferencesThreads
> SEVERE: The web application
> [/kie-drools-wb-distribution-wars-6.0.1.Final-tomcat7.0] appears to have
> started a thread named [pool-4-thread-1] but has failed to stop it. This is
> very likely to create a memory leak.
> Apr 10, 2014 2:21:40 PM org.apache.catalina.loader.WebappClassLoader
> clearReferencesThreads
> SEVERE: The web application
> [/kie-drools-wb-distribution-wars-6.0.1.Final-tomcat7.0] appears to have
> started a thread named [Thread-3] but has failed to stop it. This is very
> likely to create a memory leak.
> Apr 10, 2014 2:21:40 PM org.apache.catalina.loader.WebappClassLoader
> clearReferencesThreads
> SEVERE: The web application
> [/kie-drools-wb-distribution-wars-6.0.1.Final-tomcat7.0] appears to have
> started a thread named [pool-7-thread-1] but has failed to stop it. This is
> very likely to create a memory leak.
> Apr 10, 2014 2:21:40 PM org.apache.catalina.loader.WebappClassLoader
> clearReferencesThreads
> SEVERE: The web application
> [/kie-drools-wb-distribution-wars-6.0.1.Final-tomcat7.0] appears to have
> started a thread named [Git-Daemon-Accept] but has failed to stop it. This
> is very likely to create a memory leak.
> Apr 10, 2014 2:21:40 PM org.apache.catalina.loader.WebappClassLoader
> checkThreadLocalMapForLeaks
> SEVERE: The web application
> [/kie-drools-wb-distri

Re: [rules-users] If I have a rule that has a lot of permutation, which is the best approach to set it up? (Currently using decision table)

2014-04-11 Thread Michael Anstis
If rows have default values they will populate the cells when you add a new
row.

You could set default values, add your rows, and then remove said default
values if no longer applicable.


On 11 April 2014 13:35, SSWA  wrote:

> Attached is a sample rule decision table that I have set up.
>
> As you can see, I have designed my conditions very nicely in the picture.
> But if I were to add a new check, I will actually have to slowly key in the
> values.
>
> I'm wondering if there is any way that when I slot a condition into row 4,
> it will auto populate the other fields that are "grouped" together. This
> way, I wouldn't have to re-write those condition's information.
>
> So example if I have a new module coming in for P1 called MODULE-A, and I
> want to create a condition for it to say if the nationality is FR and
> Eligibility is Y, it is 500 dollar. I will probably click the + button at
> row 5 or even row 6. Then the fields, "P1", "Nationality", "Eligibility",
> "Fee Code" will all be populated since they are grouped, and I will just
> key
> in the Module Code.
>
> Is there any way to do this?
>
>
>
> --
> View this message in context:
> http://drools.46999.n3.nabble.com/If-I-have-a-rule-that-has-a-lot-of-permutation-which-is-the-best-approach-to-set-it-up-Currently-usi-tp4029207.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] If I have a rule that has a lot of permutation, which is the best approach to set it up? (Currently using decision table)

2014-04-11 Thread SSWA
Attached is a sample rule decision table that I have set up.

As you can see, I have designed my conditions very nicely in the picture.
But if I were to add a new check, I will actually have to slowly key in the
values.

I'm wondering if there is any way that when I slot a condition into row 4,
it will auto populate the other fields that are "grouped" together. This
way, I wouldn't have to re-write those condition's information.

So example if I have a new module coming in for P1 called MODULE-A, and I
want to create a condition for it to say if the nationality is FR and
Eligibility is Y, it is 500 dollar. I will probably click the + button at
row 5 or even row 6. Then the fields, "P1", "Nationality", "Eligibility",
"Fee Code" will all be populated since they are grouped, and I will just key
in the Module Code.

Is there any way to do this?



--
View this message in context: 
http://drools.46999.n3.nabble.com/If-I-have-a-rule-that-has-a-lot-of-permutation-which-is-the-best-approach-to-set-it-up-Currently-usi-tp4029207.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] Best practices to hand over from dev to business

2014-04-11 Thread djb
Hi,
So I've worked with Drools v5 on a few projects, and made the move to v6
yesterday. 

My programs typically have a model of pojos, plus some service utilities
that do the stuff that's easier in Java than in Drools.

I have implemented the system with DRLs and agenda groups, and one of the
next steps is to hand over to business. My comments will allow a junior
developer to maintain the program, but you'd be surprised how non-technical
the business users can be. They won't touch code.

So I'm hoping that Workbench will be what I need to facilitate the
transition.  With Drools 6, I've separated my web app from the DRL files,
which now reside in their own mavenized Jar.

Deployment is also very manual at the moment. Run mvn install, ftp war to
server, drop in Jboss.

So step 1 is probably to load the model and drl files into WB. Should a
kiesession jar have pojos too? Only the parts you want to manage in WB?

Then I presume that the main goal of WB is to provide a graphical ui to
maintain rules, with business users messing around in their sandbox, making
new snapshot versions of the rules jar?

Then i change the web app's dependency to the new snapshot, rebuild and
redeploy?

What is the best scenario, to allow business users a UI and myself a simple
deployment mechanism when business users want to test their changes, that i
can hope to achieve with Drools and it's Uberfire parts?





--
View this message in context: 
http://drools.46999.n3.nabble.com/Best-practices-to-hand-over-from-dev-to-business-tp4029206.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] Pooling stateful sessions to have threaded executions of a ruleset

2014-04-11 Thread Mercier Jonathan

Le 09/04/2014 11:20, Maxime Falaize a écrit :
I confirm that the multithreaded rules evaluation is not currently 
supported. See 
https://github.com/droolsjbpm/drools/blob/master/drools-core/src/main/java/org/drools/core/RuleBaseConfiguration.java#L683



2014-04-07 12:27 GMT+02:00 Maxime Falaize >:


I'm sorry but I don't understand what you are talking about. In
this article, there is nothing about multithreaded rules
evaluation. It just says that the Phreak algorithm is designed for
thread safety and *future* multicore processors exploitation. It
doesn't mean that it is already multithreaded. Moreover I tested
my appliciation with and without multithreaded sessions (I am
using Drools 6.0.1.Final) and I noted a faster execution in the
multithreaded one.


2014-04-04 13:53 GMT+02:00 jmercier mailto:jmerc...@genoscope.cns.fr>>:

Le 04/03/2014 09:55, Maxime Falaize a écrit :
> Hello,
>
> I want to ask you if it is a good practive to pool stateful
sessions
> for a specific ruleset to improve the execution performance.
> Actually in my application I execute my rules by calling SOAP
> webservice. For performance purpose, I test multithreaded
calls to my
> webservice and I noted that when I pool sessions in the
server side,
> it improves the performance a lot.
>
> To pool sessions, I just declare multiple ksession tag in my
> kmodule.xml :
>
> 
> 
>  
> 
> 
> 
>  
>
> In my spring webservice endpoint I just put that code to
handle the
> pool :
>
> @Endpoint
> public class ExampleEndpoint implements InitializingBean {
>
> @Autowired
> private ExampleRuleService ruleService;
>  private Map isRunningMap = new
> HashMap();
> private static final int NB_POOL_SESSIONS = 5;
>
> @PayloadRoot(localPart = "com.example.ExampleRequest")
>  @ResponsePayload
> public ExampleResponse handleRequest(
> @RequestPayload ExampleRequest request) throws
> InterruptedException {
> KieServices ks = KieServices.Factory.get();
> KieContainer kc = ks.getKieClasspathContainer();
>  while (true) {
> for (int i = 0; i < NB_POOL_SESSIONS; i++) {
> boolean run = false;
>
> synchronized (isRunningMap) {
> if (!isRunningMap.get(i)) {
> isRunningMap.put(i, true);
> run = true;
> }
> }
>
> if (run) {
> KieSession ksession =
kc.newKieSession("KSession"
> + (i + 1));
>  ExampleResponse response =
> ruleService.run(ksession, request);
> ksession.dispose();
>
> isRunningMap.put(i, false);
> return response;
>  }
> }
> Thread.sleep(100);
> }
> }
>
> public void afterPropertiesSet() throws Exception {
> for (int i = 1; i <= NB_POOL_SESSIONS; i++) {
> isRunningMap.put((i - 1), false);
>  }
> }
>
> }
>
> It works well because in my benchmark I improve 5 times the
> performance (as I have 5 different threads) but I wondered
if it is a
> good practice and if it does not hide any issues that I
could have in
> the future.
>
> Thanks for your help.
>
> --
> Maxime FALAIZE
> ___
> rules-users mailing list
> rules-users@lists.jboss.org 
> https://lists.jboss.org/mailman/listinfo/rules-users


Hi maxime,

I do not remember if use drools 6 or drools 5. If you using
drools 6.
Phreaks algorithm use multi threading according to use 'from
accummulate' far i understand here:

http://planet.jboss.org/post/drools_6_performance_with_the_phreak_algorithm

Instead to put a thread by ksession here rules evaluation are
multi-threaded.


___
rules-users mailing list
rules-users@lists.jboss.org 
https://lists.jboss.org/mailman/listinfo/rules-users




-- 
Maxime FALAIZE





--
Maxime FAL