Persisted stateful sessions and knowledge base changes (revisited)
by dunnlow
I have an Drools 5.5. application that persists a stateful session to a
database. While it was running, I made some changes to my rules (via
Guvnor). When I restarted my application it was no longer able to reload
the persisted session:
*Caused by: java.lang.RuntimeException: Unable to load session snapshot at
org.drools.persistence.session.JPASessionMarshallingHelper.loadSnapshot(JPASessionMarshallingHelper.java:96)*
FYI, I do not use a KnowledgeAgent because I have a lot of events coming in
and I only want to load the knowledgebase changes when my application starts
up.
About two years ago, a discussion occurred on this topic
(https://community.jboss.org/message/628586#628586). Unfortunately, I
haven't seen much since but I am hoping that someone has concurred this
problem (elegantly or otherwise).
Is there a common way to solve this problem? Given a persisted session what
are the steps needed to migrate it to the new ruleset?
Thanks for any insight.
-J
--
View this message in context: http://drools.46999.n3.nabble.com/Persisted-stateful-sessions-and-knowled...
Sent from the Drools: User forum mailing list archive at Nabble.com.
11 years, 3 months
Problem with PKG from guvnor
by calcacuervo
Hi Guys,
I am having a problem using Drools 5.5.
Basically, I have a ksession in stream mode.
I have a rule with an event, like this
when
myfact: EventA( main > 21 ) over window:length (1)
myfact2 : EventA( main <= 21 , this before myfact ) over window:length (2)
I also use a KnowledgeAgent and apply a changeset.
If I declare this rule directly from the changeset, as a Classpath resource,
with resource type DRL, it seems to work fine (the kbase compiles!).
But If I have the rule in a guvnor package, and I put the PKG link in my
changeset, I am getting an error:
Caused by: java.lang.NullPointerException
at
org.drools.base.evaluators.BeforeEvaluatorDefinition$BeforeEvaluator.getInterval(BeforeEvaluatorDefinition.java:268)
[drools-core-5.5.0.Final.jar:5.5.0.Final]
at
org.drools.rule.constraint.EvaluatorConstraint.getInterval(EvaluatorConstraint.java:100)
[drools-core-5.5.0.Final.jar:5.5.0.Final]
at
org.drools.reteoo.builder.BuildUtils.gatherTemporalRelationships(BuildUtils.java:326)
[drools-core-5.5.0.Final.jar:5.5.0.Final]
at
org.drools.reteoo.builder.BuildUtils.calculateTemporalDistance(BuildUtils.java:292)
[drools-core-5.5.0.Final.jar:5.5.0.Final]
at
org.drools.reteoo.builder.ReteooRuleBuilder.addRule(ReteooRuleBuilder.java:119)
[drools-core-5.5.0.Final.jar:5.5.0.Final]
at org.drools.reteoo.ReteooBuilder.addRule(ReteooBuilder.java:113)
[drools-core-5.5.0.Final.jar:5.5.0.Final]
at org.drools.reteoo.ReteooRuleBase.addRule(ReteooRuleBase.java:445)
[drools-core-5.5.0.Final.jar:5.5.0.Final]
It seems that that getOperator() is null in this evaluation:
if ( this.getOperator().isNegated() ) {
I debugged a bit, and it seems the evaluator comes in serialized from
guvnor's package.But in case of getting directly the classpath resource, it
compiles the package and it gets the real operator ok (Operator = 'before')
Do you have any idea of why it could be happening? May I be doing something
wrong? Is this a bug in guvnor?
Thanks in advance!
Demian
--
View this message in context: http://drools.46999.n3.nabble.com/Problem-with-PKG-from-guvnor-tp4025687....
Sent from the Drools: User forum mailing list archive at Nabble.com.
11 years, 3 months
Using KnowledgeAgent with loadStatefulKnowledgeSession?
by dunnlow
Hello, I am using jBPM 5.4 with persistence and have long running processes
and make make changes to the knowledge base periodically (via drools guvnor
5.5). I use JPAKnowlegeService.loadStatefulKnowledgeSession(...) to retrieve
my existing knowledge session. When I make a change to the rule base (via
drools 5.5 guvnor) and then try to restart my application (and reload the
knowledgesession) I get an exception:
java.lang.RuntimeException: Unable to load session snapshot
at
org.drools.persistence.SessionMarshallingHelper.loadSnapshot(SessionMarshallingHelper.java:96)
.
.
Caused by: java.lang.NullPointerException
at
org.drools.common.Scheduler$activationTimerInputMarshaller.deserialize(Scheduler.java:230)
I am NOT currently using a KnowledgeAgent and it seems like it should be
able to help. I have read over the drools forum and this one and see a few
discussions on the topic (https://community.jboss.org/thread/172818) but
nothing concrete to put me on the right path.
The examples with knowledgeagent I have found assume that I am calling:
StatefulKnowledgeSession ksession = kbase.newStatefulKnowledgeSession();
Can someone please show/explain how I can reload an existing persisted
knowledgesession given changes in my knowledge base? (for example, can the
knowledgeagent and JPAKnowlegeService.loadStatefulKnowledgeSession be used
together? If not, do I load the existing statefulknowledgesession by some
other means?)
I am using Spring-based configuration. Thanks for any insight.
-J
--
View this message in context: http://drools.46999.n3.nabble.com/Using-KnowledgeAgent-with-loadStatefulK...
Sent from the Drools: User forum mailing list archive at Nabble.com.
11 years, 3 months
Is drools the solution for my requirement.
by nitind
Hi,
We have 200 odd rules to be configured and wanted to know if drools can
be the optimum solutions. The rules are broadly classified into 2 categories
example 1 : We need to compare invoice no value in 10 documents and
if it matches perform A if it does not match perform B
The catch is the 10 different document may not
have the same Keyword i.e. Invoice no, instead it can Bill no, Invoice
number, Bill #, Inv etc.
example 2 : Search for Key word like Ferrari, BMW , if found need to
check if the individual is Authorized agent.
Question : Can the above be implement using Drools, second is it
worth the effort or just code if else in Java and get it done.
Thanks in advance.
Regards
Nitin
--
View this message in context: http://drools.46999.n3.nabble.com/Is-drools-the-solution-for-my-requireme...
Sent from the Drools: User forum mailing list archive at Nabble.com.
11 years, 3 months
Guvnor - more than one resource in changeset.xml
by rganesh84
I have 2 packages in Guvnor UI having different set of rule assets in it.
pkg1 -> UI rules
pkg2 -> Business rules
In the java application code base, is it mandatory to have 2 change set xmls
with different package contents?
[Java] // for UI rules
kagent.applyChangeSet(ResourceFactory.newClassPathResource("guvnor-tomcat-pkg1-changeset.xml"));
[/Java]
[Java] // for business rules
kagent.applyChangeSet(ResourceFactory.newClassPathResource("guvnor-tomcat-pkg2-changeset.xml"));
[/Java]
Can this be achieved having only one changeset holding multiple packaged
rules?
[change set]
<add>
<resource
source='http://server:8080/guvnor-tomcat/rest/packages/com.pkg1/source'
type='DRL' basicAuthentication="enabled" username="admin" password="admin"
/>
</add>
[/changeset]
If i add a resource to add tag, how do I call it in Java code?
--
View this message in context: http://drools.46999.n3.nabble.com/Guvnor-more-than-one-resource-in-change...
Sent from the Drools: User forum mailing list archive at Nabble.com.
11 years, 3 months
Line breaks in DSLR
by Stefan
I have written a simple DSLR-rule with a rather long sentence in the
when-part:
-----------------------------------------------------------------
rule "NR3620"
when
tariff number of a position starts with "0301" and the duty measure
is one of "112", "122", "142", "141", "143" and code of condition is "M" and
customs value of position is less than the reference value of condition
then
Error F3620
end
-----------------------------------------------------------------
When I try to break up the sentence into serveral lines for better
readability I get an error. This does not word:
-----------------------------------------------------------------
rule "NR3620"
when
tariff number of a position starts with "0301" and
the duty measure is one of "112", "122", "142", "141", "143" and
code of condition is "M" and
customs value of position is less than the reference value of
condition
then
Error F3620
end
-----------------------------------------------------------------
Here is the corresponding expander (line breaks at the lhs of the 5th
when-clause are ok!):
-----------------------------------------------------------------
[when]condition code=condCode
[when]customs value=custValue
[when]reference value=condAmount
[when]less than=<=
[when]
tariff number of a position starts with {tariffNumberPrefix} and
the duty measure is one of {dutyMeasureCodes} and
code of condition is {conditionCode} and
{propPosition} of position is {comparator} the {propCondition} of condition
=
$measure: DutyMeasure(
tariffCode str[startsWith] {tariffNumberPrefix},
addCodeNumber in ({dutyMeasureCodes})
);
$condition: Condition(
condCode == {conditionCode}
)
$position: ImportPosition(
tariffNumber str[startsWith] {tariffNumberPrefix},
{propPosition} {comparator} $condition.{propCondition}
);
[then]
Error {code} = System.out.println("{code}");
-----------------------------------------------------------------
Any idea how to break up the long DSL-sentence into several lines?
Thx Stefan
--
View this message in context: http://drools.46999.n3.nabble.com/Line-breaks-in-DSLR-tp4025707.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
11 years, 3 months
issue running Drools Expert 6.0 CR2 inside OSGi
by yelin66
I was able to have Drools Expert 5.3 running inside OSGi. However, the
bundles from 5.4/5.5 were having problem even to start inside the OSGi
container. I tried 6.0 CR2 recently, and encountered the following issue:
• Basically, my model class(es) failed to be loaded from the drools-core &
drools-compiler bundles, although the similar code worked in 5.3. I did some
investigation, and noticed that in 5.3 both drools-core & drools-compiler
have “DynamicImport-Package: *” in the bundle’s manifest file. I tried
manually adding “DynamicImport-Package: *” to the bundle’s manifest for 6.0
CR2, and that worked.
So what’s your suggestions on how to run 6.0 bundles inside OSGi? Would
appreciate your feedback.
--
View this message in context: http://drools.46999.n3.nabble.com/issue-running-Drools-Expert-6-0-CR2-ins...
Sent from the Drools: User forum mailing list archive at Nabble.com.
11 years, 3 months
How Answers to community question Appear on more than one site
by Zahid Ahmed
Hi,
I also wanted to know that I replied on rules-users mailing list and now my answer is listed on http://www.marshut.com/ website instead of jboss community. Some answers get displayed at nabble.com.... Howcome some answers are visible on marshut and some on nabble. I just want to know is this a new technique to balance the load on community site.
Thanks and Best Regards,
Zahid Ahmed
11 years, 3 months
Persistence and event expiry
by DanielStahl
Hi,
I'm quite new to Drools, and very excited about the possibilities it offers,
but I need a bit of advice. I'm using Drools 6.0.0.CR1 to run a Stream
session in my application.
The application will be running for extended periods of time, so I need to
be able to delete facts over time. I can solve that nicely by declaring them
as events and letting them expire either implicitly or explicitly.
I also need the session to be persistent, so that if the application
restarts it resumes from any previously saved state. I can do that by
creating my own ObjectMarshallingStrategy and adding an EventListener,
marshalling upon insert/update/deletion of facts, and then unmarshalling
upon startup. That works.
My problem is that unmarshalled events never expire. To exemplify: Event A
will expire after 30s. Before that happens, though, the application restarts
and unmarshals the session. Event A is now still in the fact base of the
restarted session, but it will never expire. Since I'm new to Drools, I'm
assuming I'm doing something wrong, but I'm not sure what. So my question
is: is my setup reasonable, or is there a better way to achieve this? Is
this working as intended, or a bug? If working as intended, is there a
workaround?
Best regards,
Daniel Ståhl
--
View this message in context: http://drools.46999.n3.nabble.com/Persistence-and-event-expiry-tp4025697....
Sent from the Drools: User forum mailing list archive at Nabble.com.
11 years, 3 months