Re: [rules-users] KnowledgeAgent to update knowledge base built with Guvnor pkg

2013-05-03 Thread riri
Thank you very much for the detailed explanation, things are clearer now. I
would have liked to be able to initialize the KA with an empty KB but I need
to be able to set the configuration options for it and for now I don't see
how that is done. Can the options, like STREAM mode be set when creating the
KB from the KA?

Otherwise I will continue to re-create the environment before running a
session since for now it is the only option that works.

Best regards



--
View this message in context: 
http://drools.46999.n3.nabble.com/Re-rules-users-KnowledgeAgent-to-update-knowledge-base-built-with-Guvnor-pkg-tp4023608p4023654.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] KnowledgeAgent to update knowledge base built with Guvnor pkg

2013-05-02 Thread riri
Ok so I've added the listeners and I have run 2 scenarios:

1. I do not recreate the KA before I re-run a session, and all the info that
I get even after having deleted a rule from the package is :

// at the beginning
[2013-05-02 23:23:32,031:info] ResourceChangeNotification scanner has
started
[2013-05-02 23:23:32,032:debug] ResourceChangeScanner attempt to scan 2
resources
[2013-05-02 23:23:32,033:debug] ResourceChangeScanner thread is waiting for
60 seconds.
[2013-05-02 23:23:32,034:info] ResourceChangeNotification has started
listening for ChangeSet publications
[2013-05-02 23:23:32,034:debug] ResourceChangeNotification thread is waiting
for queue update
[2013-05-02 23:23:32,232:info] ResourceChangeScanner reconfigured with
interval=20
[2013-05-02 23:23:32,232:info] ResourceChangeScanner reconfigured with
interval=20
[2013-05-02 23:23:32,232:info] ResourceChangeNotification scanner has
stopped
[2013-05-02 23:23:32,233:info] ResourceChangeNotification scanner has
started

// after starting the services
[2013-05-02 23:23:32,233:debug] ResourceChangeScanner attempt to scan 2
resources
[2013-05-02 23:23:32,234:debug] ResourceChangeScanner thread is waiting for
20 seconds.

2. I re-create the KA before I run a session, and dispose of the previous
KA, and this is what I get without even making any changes to the rules (the
same messages stating that the services have started are present but not
included):

// after disposing of agent
[2013-05-02 23:23:50,466:debug] KnowledgeAgent unsubscribing from
resource=[ReaderResource resource=null encoding='null']
[2013-05-02 23:23:50,466:debug] ResourceChangeNotification unsubscribing
listener=org.drools.agent.impl.KnowledgeAgentImpl@9a8636 to
resource=[ReaderResource resource=null encoding='null']
[2013-05-02 23:23:50,467:debug] ResourceChangeScanner unsubcribing
notifier=org.drools.io.impl.ResourceChangeNotifierImpl@e171b2 to
resource=[ReaderResource resource=null encoding='null']
[2013-05-02 23:23:50,467:debug] ResourceChangeScanner
resource=[ReaderResource resource=null encoding='null'] now has no
subscribers
[2013-05-02 23:23:50,467:debug] KnowledgeAgent unsubscribing from
resource=[ClassPathResource path='ruleFiles/BasicWithFacts.drl']
[2013-05-02 23:23:50,467:debug] ResourceChangeNotification unsubscribing
listener=org.drools.agent.impl.KnowledgeAgentImpl@9a8636 to
resource=[ClassPathResource path='ruleFiles/BasicWithFacts.drl']
[2013-05-02 23:23:50,467:debug] ResourceChangeScanner unsubcribing
notifier=org.drools.io.impl.ResourceChangeNotifierImpl@e171b2 to
resource=[ClassPathResource path='ruleFiles/BasicWithFacts.drl']
[2013-05-02 23:23:50,467:debug] ResourceChangeScanner
resource=[ClassPathResource path='ruleFiles/BasicWithFacts.drl'] now has no
subscribers

// after re creating the agent
[2013-05-02 23:23:50,698:debug] KnowledgeAgent building resource map
[2013-05-02 23:23:50,699:debug] KnowledgeAgent no resource mapped for
type=TypeDeclaration{typeName='StateEvent', role=FACT, format=POJO,
kind=CLASS, nature=DECLARATION}
[2013-05-02 23:23:50,699:debug] KnowledgeAgent mapping
resource=[ClassPathResource path='ruleFiles/BasicWithFacts.drl'] to
KnowledgeDefinition=TypeDeclaration{typeName='StateEvent', role=FACT,
format=POJO, kind=CLASS, nature=DECLARATION}
[2013-05-02 23:23:50,699:debug] KnowledgeAgent notifier subscribing to
resource=[ClassPathResource path='ruleFiles/BasicWithFacts.drl']
[2013-05-02 23:23:50,699:debug] ResourceChangeNotification subscribing
listener=org.drools.agent.impl.KnowledgeAgentImpl@1eaa99b to
resource=[ClassPathResource path='ruleFiles/BasicWithFacts.drl']
[2013-05-02 23:23:50,698:info] KnowledgeAgent has started listening for
ChangeSet notifications
[2013-05-02 23:23:50,699:debug] ResourceChangeScanner subcribing
notifier=org.drools.io.impl.ResourceChangeNotifierImpl@e171b2 to
resource=[ClassPathResource path='ruleFiles/BasicWithFacts.drl']
[2013-05-02 23:23:50,699:debug] KnowledgeAgent mapping
resource=[ClassPathResource path='ruleFiles/BasicWithFacts.drl'] to
KnowledgeDefinition=[Rule name=sensor has reading value, agendaGroup=MAIN,
salience=12, no-loop=true]
[2013-05-02 23:23:50,699:warning] KnowledgeAgent: impossible to add a map
for a null resource! skiping.
[2013-05-02 23:23:50,699:debug] KnowledgeAgent mapping
resource=[ReaderResource resource=null encoding='null'] to
KnowledgeDefinition=[Rule name=bla, agendaGroup=MAIN, salience=12,
no-loop=true]
[2013-05-02 23:23:50,699:debug] KnowledgeAgent notifier subscribing to
resource=[ReaderResource resource=null encoding='null']
[2013-05-02 23:23:50,699:debug] ResourceChangeNotification subscribing
listener=org.drools.agent.impl.KnowledgeAgentImpl@1eaa99b to
resource=[ReaderResource resource=null encoding='null']
[2013-05-02 23:23:50,699:debug] ResourceChangeScanner subcribing
notifier=org.drools.io.impl.ResourceChangeNotifierImpl@e171b2 to
resource=[ReaderResource resource=null encoding='null']
[2013-05-02 23:23:50,699:warning] KnowledgeAgent: impossible to add a map
for a null

Re: [rules-users] KnowledgeAgent to update knowledge base built with Guvnor pkg

2013-05-02 Thread riri
Thank you for the tips! I did change the scanning interval to 20s and I wait
before restarting the session. I have also tried to compile the package
manually in Guvnor after changing a rule but still no effect. The problem is
that I use the embedded editor in my application for creating a rule and so
normally the user would not have access to Guvnor to retrigger the build.
Programatically would that mean to use a builder to rebuild the packages but
then wouldn't I be creating a new knowledge base? 

And also, what line should I include in the log4j config file to enable the
debug messages for Drools? Or should I just have the root logger set to
debug? At the moment I do not see the message at all.

I apologize if some of my questions are dumb, I'm still trying to get my
head around how everything works together. 

Best regards 



--
View this message in context: 
http://drools.46999.n3.nabble.com/Re-rules-users-KnowledgeAgent-to-update-knowledge-base-built-with-Guvnor-pkg-tp4023608p4023643.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] KnowledgeAgent to update knowledge base built with Guvnor pkg

2013-05-02 Thread riri
As an addition to my post earlier, there is an error in the loggs regarding
the change-set.xml:

ERROR ExtensibleXmlParser:666 - (null: 6, 119): cvc-elt.1 : Declaration of
element 'change-set' not found.

My change-set.xml file is as follows:



http://drools.org/drools-5.0/change-set";
 xmlns:xs="http://www.w3.org/2001/XMLSchema-instance";
 xs:schemaLocation="http://drools.org/drools-5.0/change-set.xsd 
   
http://anonsvn.jboss.org/repos/labs/labs/jbossrules/trunk/drools-api/src/main/resources/change-set.xsd";
>

   
 
   

 

The resources are added correctly and there are no other errors however.



--
View this message in context: 
http://drools.46999.n3.nabble.com/Re-rules-users-KnowledgeAgent-to-update-knowledge-base-built-with-Guvnor-pkg-tp4023608p4023625.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] KnowledgeAgent to update knowledge base built with Guvnor pkg

2013-05-02 Thread riri
Here is the code I am using to create the knowledge base, knowledge agent and
to retrieve the resources:

public static KnowledgeBase createKnowledgeBase(List
resources, 
 EventProcessingOption eventProcessingOption)
{
KnowledgeBuilder builder = 
KnowledgeBuilderFactory.newKnowledgeBuilder();

for (DroolsResource resource : resources) 
{
logger.info("Resource: " + resource.getType() + ", path 
type="
+ resource.getPathType() + ", path=" + 
resource.getPath());
switch (resource.getPathType()) 
{
case CLASSPATH:
   
builder.add(ResourceFactory.newClassPathResource(resource.getPath()),
resource.getType());
break;
case FILE:
   
builder.add(ResourceFactory.newFileResource(resource.getPath()),
resource.getType());
break;
case URL:
UrlResource urlResource = (UrlResource) 
ResourceFactory
.newUrlResource(resource.getPath());

if (resource.getUsername() != null) 
{
logger.info("Setting authentication for: " +
resource.getUsername());
urlResource.setBasicAuthentication("enabled");
urlResource.setUsername(resource.getUsername());
urlResource.setPassword(resource.getPassword());
}

builder.add(urlResource, resource.getType());
break;
default:
throw new IllegalArgumentException(
"Unable to build this resource path type.");
}
}

if (builder.hasErrors()) {
throw new RuntimeException(builder.getErrors().toString());
}

KnowledgeBaseConfiguration conf =
KnowledgeBaseFactory.newKnowledgeBaseConfiguration();
   // setting the STREAM option
conf.setOption(eventProcessingOption);
// modify the default identity compare mode to equality
conf.setOption(AssertBehaviorOption.EQUALITY);

KnowledgeBase knowledgeBase =
KnowledgeBaseFactory.newKnowledgeBase(conf);
knowledgeBase.addKnowledgePackages(builder.getKnowledgePackages());

return knowledgeBase;

}

public static KnowledgeAgent createKnowledgeAgent(String
knowledgeAgentName, KnowledgeBase knowledgeBase)
{
KnowledgeAgentConfiguration aconf =
KnowledgeAgentFactory.newKnowledgeAgentConfiguration();

aconf.setProperty("drools.agent.newInstance", "false"); 
KnowledgeAgent kagent =
KnowledgeAgentFactory.newKnowledgeAgent(knowledgeAgentName, knowledgeBase,
aconf);

ResourceFactory.getResourceChangeScannerService().start();
ResourceFactory.getResourceChangeNotifierService().start();

return kagent;
}

public DroolsResource getGuvnorResource(User user)
{
String packageName = user.getUsername();
String guvnorBinaryResourceUrl =
"http://127.0.0.1:8080/guvnor/rest/packages/"; + packageName + "/binary";
return new DroolsResource(guvnorBinaryResourceUrl, 
ResourcePathType.URL,
ResourceType.PKG, credentials.getUserPrincipal().getName(),
credentials.getPassword()); 
}

Where the DroolsResource is a custom class to hold information about a
resource:

public class DroolsResource
{

private String path;
private ResourcePathType pathType;
private ResourceType type;
private String username = null;
private String password = null;

 //getters, setters and constructors
}

To initialize the environement I just call the method to create the
knowledge base once I have the DroolsResource and then the method to create
the knowledge agent. Afterwards I create a statefull knowledge session using
the getKnowledgeBase() of the agent. Would the problem be the Guvnor url
that I am using? I used the rest version since it sais that it builds the
package automatically. Or the fact that the url is not in a change-set.xml
file? 

When I run the session the first time (via the fireUntilHalt() in a separate
thread), rules get executed correctly and I call the halt() method to stop
it. If I then go and change a rule in the package and restart the session
then no changes are taken into account. Is the way I am executing the
s

Re: [rules-users] KnowledgeAgent to update knowledge base built with Guvnor pkg

2013-05-01 Thread riri
Nobody has any ideas on how to solve this? I am willing to try anything that
might work short of re-creating the knowledge base everytime I start a new
session. 

And when using the changeSet() method for the knowledge agent, how would one
set the knowledge base properties? Like functioning in STREAM mode and not
CLOUD.

Please, anyone, I really need your help.



--
View this message in context: 
http://drools.46999.n3.nabble.com/KnowledgeAgent-to-update-knowledge-base-built-with-Guvnor-pkg-tp4023592p4023603.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] KnowledgeAgent to update knowledge base built with Guvnor pkg

2013-04-30 Thread riri
Hello everyone,

I am trying to take advantage of the automatic uploading that the
KnowledgeAgent provides and am using the 5.5.Final Drools version. The
Drools Expert documentation states that one can use an existing knowledge
base to create an agent, and the agent will subscribe to the resources that
it finds (Example 3.26. Using an existing KnowledgeBase).

I am at first creating the knowledge base using a set of .drl files defined
in a change-set file and also a Guvnor url :
http://127.0.0.1:8080/guvnor/org.drools.guvnor.Guvnor/package//LATEST.
I then create the knowledge agent as shown in Example 3.26 of the
documentation. The problem is that if I modify the Guvnor package (add or
remove a rule) and then rerun a stateful knowledge session, the knowledge
base is not updated. I thought that I needed to build the package in Guvnor
every time I modify it but doing so does not solve the problem. Modifying
the rules in the change-set files seems to update the knowledge base.

I start the ResourceChangeScanner and ResourceChangeNotifier and if I call
isMonitorChangeSetEvents() and isScanResources() they return true. And also,
whenever  I create a session, I use the getKnowledgeBase() method and am not
caching it somewhere in my program. Should I not be creating the agent with
an existing knowledge base and instead use the applyChangeSet() method? If
so, how would I be able to configure the knowledge base to use
AssertBehaviorOption.EQUALITY? 

Thany you very much for any help or tips to point me in the right direction.

Best regards






--
View this message in context: 
http://drools.46999.n3.nabble.com/KnowledgeAgent-to-update-knowledge-base-built-with-Guvnor-pkg-tp4023592.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] Working memory - database synchronisation approach

2013-03-28 Thread riri
I may not have explained the architecture I have very well so here it is: I
have plain JPA entities, some of which I want to insert as facts in the
working memory, all entities have repositories defined for them via the
Spring Data JpaRepository and these repositories are called by Spring
Services whenever I need to retrieve, save, delete an entity from the
database. This works well on its own, the methods in the services are all
marked as transactional via AOP pointcuts in the Spring configuration file,
but I want to be able to persist the changes made to an entity from the
working memory to the database and for that I thought about calling the
Spring services inside the WorkingMemoryEventListener.

I think the problem might be with the way I call the fireUntilHalt() method
in a separate thread and the fact that the transaction manager is shut down
at the end of the test, before the entities have time to be updated in the
database. In my test I have 2 rules and the first rule makes modifications
to an entity that trigger the second one. The modifications from the first
rule are saved, the second rule gets triggered but the transaction manager
and the spring context are closed before the update can be made for the
entities in the second rule. Would this be a problem related to the test
itself since in normal functioning the spring application and the
transaction manager would be open unless the whole application is shut down?

I will try and do some more tests to see how to solve this even though I am
not sure if what I am doing is the right way to go. Thank you for the
insight Steve!



--
View this message in context: 
http://drools.46999.n3.nabble.com/Working-memory-database-synchronisation-approach-tp4023094p4023109.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] Working memory - database synchronisation approach

2013-03-28 Thread riri
Thank you very much for the quick replies!

I would very much like to avoid having persistence in my rules but I am not
sure how to get notified of changes of an object inside the working memory
so that the service to update it can be called outside the
WorkingMemoryEventListener. 

What I have now is a User entity that has a field which is a
KnowledgeEnvironment. This object is a plain POJO (not Spring bean) that
holds a reference to a KnowledgeAgent and a StatefulKnowledgeSession and has
a method to start a new Thread with fireUntilHalt (and other methods to
create the agent and the session). If I call this method from a unit test
that is marked with @Transactional and have a delay in the thread execution,
the changes get persisted to the database. Without the delay I get an
exception 

Caused by: bitronix.tm.internal.BitronixSystemException: cannot start a new
transaction, transaction manager is shutting down

I imagine this is because the thread is trying to execute after the
transactional context of the unit test has been closed. I do not fully
understand how having access to the Spring context in the separate thread
could help me. Again, I do think that the way I am doing this is flawed
since I need some way to keep the transaction context open so that the
updates can be performed but I have very little experience in the matter.
Should I have a Spring service that is marked with Transactional and can be
called using a KnowledgeSession to span a new thread instead of the method
inside the KnowledgeEnvironment? 

Any insight is highly appreciated!



--
View this message in context: 
http://drools.46999.n3.nabble.com/Working-memory-database-synchronisation-approach-tp4023094p4023100.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] Working memory - database synchronisation approach

2013-03-28 Thread riri
Hello everyone,

I am currently working on a Spring, Hibernate, Bitronix project and am
trying to integrate Drools functionality. I have a set of JPA Entities that
I can manage using Spring Data and Hibernate and I would like to use these
entities as facts inside a StatefulKnowledgeSession. As I understand it, I
need to have some mechanism of keeping the facts inside the working memory
in sync with the database and what I mean by that is:
 1. update the facts in working memory when they are changed from outside
 2. update the facts in the database when a RHS part of a rule changes
properties

This article  http://www.ibm.com/developerworks/java/library/j-drools5/
   gives some
pointers on how to achieve 1. using AOP but in my case I do not have a
global knowledge session to insert, I need to be able to create a knowledge
base for each user of the application since each user will need to have his
own set of rules independent from other users.

What would be the best practices for achieving the synchronisation?
Currently for 1. I am updating the fact manually by retrieving the object
and calling update from java code. For 2. I have a
WorkingMemoryEventListener that is configured as a Spring @Component with
autowired services that can perform CRUD actions on entities and which are
called on objectUpdated.

I am new to all these technologies so I do not know if this is a good way to
go. I have a unit test where a rule modifies a property and the object is
updated in the database but if the Thread with the fireUntilHalt method is
not paused, the test finishes and the JTA manager is shut down before the
rules can fire and the transaction in the objectUpdated can be executed.

I would be very grateful for any insight from the more experienced users
that have come across such requirements before.

Best regards



--
View this message in context: 
http://drools.46999.n3.nabble.com/Working-memory-database-synchronisation-approach-tp4023094.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] Delpoying Guvnor 5.5.0 on Tomcat 7.0.34 does not work

2013-02-17 Thread riri
Hi,

I installed Guvnor 5.5.0 on my Tomcat 7.0.35 and got the same exception as
you. What I did was to edit the web.xml file of the drools-guvnor/WEB-INF/
folder to include the following lines :


  
   org.jboss.seam.transaction.disableListener
   true


This removed the nullPointerException for me, hope it helps you as well. 

Best regards



--
View this message in context: 
http://drools.46999.n3.nabble.com/Delpoying-Guvnor-5-5-0-on-Tomcat-7-0-34-does-not-work-tp4022357p4022359.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] User specific packages for Guvnor

2013-01-30 Thread riri
Hello everyone,

I am interested in working with Guvnor and would like to know if rule
packages can be user specific. For example I would need to have each user be
able to have his own rules to work on and have only these ones available the
next time he logs in. I think that would be the same as having a separate
knowledge base per user but I am not exactly sure what settings should be
configured so that the user only has access to his knowledge base.
Afterwards I need to recover the user specific packages separately using the
knowledge agent.

Has anyone ever used Guvnor in a similar manner? I am just starting with it
and would appreciate some input from more experienced users.

Best regards 



--
View this message in context: 
http://drools.46999.n3.nabble.com/User-specific-packages-for-Guvnor-tp4021950.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] DSRL rule access in web editor

2013-01-24 Thread riri
Hi,

I did take a look at the editor for the dsrl rules and that's why I wanted
to use it because it has great functionality. Sadly it might be too powerful
for unexperienced users and I have to find a way to implement my own dsrl
file reader and create an interface for it. 

Thank you very much though for your detailed answer, it helps at least to
know in which direction to go.

Best regards



--
View this message in context: 
http://drools.46999.n3.nabble.com/DSRL-rule-access-in-web-editor-tp4021793p4021804.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] DSRL rule access in web editor

2013-01-24 Thread riri
Hello everyone,

I need to provide a way to allow non technical users to modify and possibly
create rules by using a web based editor. I thought about using Guvnor
because it already has validation functionality for the dsrl rule files and
I wouldn't have to implement that from scratch. The problem is that the
interface seems very complex and I have to provide something very simple, in
the style of "drag and drop". 

Would there be a way to achieve this without having to dig through the whole
Guvnor source code? Is there a way to recover rule objects from rule
packages and modify the conditions parameters? The idea is not to modify the
.dsrl file directly but having a tool to display the information in a way
that the user can interact with the rule in a safe way.

Thank you very much for any help you can give me.   



--
View this message in context: 
http://drools.46999.n3.nabble.com/DSRL-rule-access-in-web-editor-tp4021793.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] Web services and Drools

2013-01-14 Thread riri
Stephen Masters wrote
> The main risk would be memory usage if you have a large knowledge base or
> lots of facts, as a knowledge base and session is relatively memory
> hungry. Depends on how many users you have I guess.

Yes, I am aware of the potential memory problems but as of now I do not have
other ideas on how to meet the requirements. Spring is a very popular
framework and I will be taking it into account into my choices, so thank you
for offering to help me out.



--
View this message in context: 
http://drools.46999.n3.nabble.com/Web-services-and-Drools-tp4021509p4021520.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] Web services and Drools

2013-01-14 Thread riri
Thank you for your very quick replies. 


> You just need to create a Spring bean to act as the interface to your
> knowledge
> base. That way, Spring ensures that you have only one knowledge base
> instance in play, so it is configured and compiled when the application
> starts.

Does this mean that you can not have more than one knowledge base
configured? My application basically needs to offer the ability to edit and
test a user's own rules and facts (in a way similar to what Guvnor does but
much more simplified) and I do not know if that can be done using just one
knowledge base and sessions. I was thinking of having a separate knowledge
base per user and using a KnowledgeAgent for updating but I have yet to test
this approach.





--
View this message in context: 
http://drools.46999.n3.nabble.com/Web-services-and-Drools-tp4021509p4021515.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] Web services and Drools

2013-01-14 Thread riri
Hello everyone,

I need to develop a web application that includes Drools as its rule engine
and would like to expose its functionality as web services. I would
appreciate some expert opinion on which framework would be easiest to learn
and to work with. Some of the posts I have seen regarding Drools and OSGi
refer to it as a "nightmare". Is that still true with the current version?
If anyone has had any experience with Spring, EJB or other and would like to
share I would be very interested since I am new to this domain. If there is
a case to be made about not using a framework at all then I would also like
to hear you out.

Best regards, 



--
View this message in context: 
http://drools.46999.n3.nabble.com/Web-services-and-Drools-tp4021509.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] Rules with variable timers

2012-12-19 Thread riri
Thank you for the detailed response and clarifications. I agree that using a
timer for my purpose is not the best idea and am going to try and make use
of event timestamps and then check these values inside the rules.

I understand that by default the timestamp for a given event is read from
the Session Clock and assigned to the event at the time the event is
inserted into the working memory. Is there any way to access these values
from inside the .drl file or do I have to set my own values using the
@timestamp in order to have such access?

As a possible solution I tried setting a timestamp attribute inside an event
at creation time, with a value taken from the session clock.
 
in .drl file : 
declare StateEvent
@role(event)
@timestamp(timestamp)
end  

in java code :
 SessionClock clock = ksession.getSessionClock();
 entryPoint.insert(new StateEvent(motionSensor, clock.getCurrentTime()));

I am doing this in order to have real and pseudo clock functionality for
testing, switching between the two while using almost the same code (calling
advanceTime method for the pseudo clock is basically the only difference).
It serves my purpose but I was wondering if such an implementation could
have unwanted consequences that I am overlooking.

Regards



--
View this message in context: 
http://drools.46999.n3.nabble.com/rules-users-Rules-with-variable-timers-tp3262197p4021247.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] Rules with variable timers

2012-12-18 Thread riri
Hy,

Thank you very much for your response, I will definitely think about using
declared types for user input. I'm not exactly sure I understood how the
attributes of UserParameter are set from outside the rule file in the code
you posted. 

I found that in the documentation in section  5.7.6. "Accessing Declared
Types from the Application Code" it is stated that these types are generated
at knowledge base compilation time. Would it be necessary to create a new
knowledge session each time these values are modified or can a previously
created session be used? 

Lastly, I assume that the timer still has to be created with constant values
and there is no way around that.

I will be testing the declared type functionality myself to see how it works
but any response I get is greatly appreciated.

Thank you for your time!
Regards



--
View this message in context: 
http://drools.46999.n3.nabble.com/rules-users-Rules-with-variable-timers-tp3262197p4021239.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] Rules with variable timers

2012-12-18 Thread riri
Hy,

I would also be interested in having a timer working with variables. In my
case I need to have a rule that fires when an event is detected inside a
certain interval of time (say 22h-07h in a day), and this interval should be
configurable at runtime. I tried using a global value but I get an "Unable
to build set timer" error.

Another way to do this I guess would be to put a timestamp attribute in my
event class and check if the value is inside the interval but I was looking
forward to using the functionality of the cron timer.. Would it be possible
to use domain specific language parameters {} in the timer? It would really
be helpful to be able to use some sort of variable since the whole idea
behind my application is to allow the users to set values in the rules
without having to directly modify the .drl file.

If there are better ideas out there I'm open to suggestions since I'm just
starting with Drools and Fusion. 

Regards



--
View this message in context: 
http://drools.46999.n3.nabble.com/rules-users-Rules-with-variable-timers-tp3262197p4021237.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 scalability in home automation scenarios

2012-11-16 Thread riri
Thank you for your input! A separate KB for each user seems to me to be a
"cleaner" solution at this time since I'm not sure how to work with rule
packages and parametrized facts between users. I was also considering using
the session for testing purposes, letting the user create test cases for his
configuration. 

Regarding the expense of creating the KB I have seen some suggestions of
only creating it the first time the user loggs in and then serializing it
and then loading it from the database when the user re-connects. I am most
worried about the heap/perm gen requirements for the jvm when having 100 KBs
at the same time, each running with multiple sessions.

I am definitely going to evaluate the rules and see if they can be made to
be more generic and allow the application to use only sessions. 

Thanks again for the quick responses! 



--
View this message in context: 
http://drools.46999.n3.nabble.com/Drools-scalability-in-home-automation-scenarios-tp4020855p4020868.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 scalability in home automation scenarios

2012-11-16 Thread riri
Thank you for your response! Yes, you are right, there will be some rules
that are absolute and available to all the users so a single knowledge base
approach would make sense. From what I can gather from the Drools Expert
documentation you can have a knowledge agent that can update the knowledge
base if new resources are added. In this way one can add new rule files,
please correct me if I'm wrong on this one. 

My first question is, is there a mechanism to differentiate between the
rules defined by each user and not have all of them apply? For example if
one user has a rule that turns on the heating when the temperature drops
below 16 degrees and another for 18 degrees? I am still trying to figure out
how the knowledge base, sessions and the working memory work together so
please bear with me.

My second question is, if rule execution is possible in a separate manner
depending on the user and everything could be done using sessions, how would
drools perform when having 100 or more of these sessions working
concurrently on the same knowledge base? 

Again, extremely grateful for all your input, time and patience!



--
View this message in context: 
http://drools.46999.n3.nabble.com/Drools-scalability-in-home-automation-scenarios-tp4020855p4020864.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] Drools scalability in home automation scenarios

2012-11-16 Thread riri
Hy everyone,

I have recently decided to use Drools in my project and being a newbie I
would greatly appreciate some input. The idea is to have a web application
that simulates home automation using rules. The user could define the
configuration of his home environment (based on virtual representation of
sensors and actuators), specify rules and execute them to see how the
configuration and the rules work together.

Seeing that I have very little experience with Drools I would like to know
how drools expert would perform if you should have 100 or more users using
the web app concurrently. In some other posts they suggest creating sessions
for each user in the knowledge base but the rules would not be the same for
each house so the knowledge base would essentially need to be different.
Should a new instance of a knowledge base be created for each user? Is there
a different way to do this since creating a knowledge base is supposed to be
"expensive"? 

Sorry for the long post but I meant to give some context to the question
that could maybe help the experts. If anyone has had experience with such a
thing or can give me links to useful material it would be really helpful. 

Regards 



--
View this message in context: 
http://drools.46999.n3.nabble.com/Drools-scalability-in-home-automation-scenarios-tp4020855.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