Serialization issue with StateKnowledgeSession
by chrisLi
Hi, all
I have a requirement to serialzie a stateful session as a snapshot.
private void serialize(OutputStream out) throws IOException{
System.out.println("writing");
DroolsObjectOutputStream droolsOut = new DroolsObjectOutputStream(
(OutputStream) out);
droolsOut.writeLong(counter);
droolsOut.writeLong(clock.getCurrentTime());
droolsOut.writeObject(this.knowledgeBase);
Marshaller marshaller = createSerializableMarshaller(this.knowledgeBase);
marshaller.marshall(droolsOut, this.session);
droolsOut.close();
System.out.println("written");
}
I used the above code to serialize the knowledgebase and session into a file
simultaneously and it works well. Then I used the following code to attempt
to deserialize them, but I failed.
private void deserialize(InputStream in) throws IOException,
ClassNotFoundException {
System.out.println("reading");
DroolsObjectInputStream droolsIn = new DroolsObjectInputStream(
(InputStream) in);
this.counter = droolsIn.readLong();
long clockTime = droolsIn.readLong();
this.knowledgeBase = (KnowledgeBase) droolsIn.readObject();
Marshaller marshaller = createSerializableMarshaller(this.knowledgeBase);
this.session = marshaller.unmarshall(droolsIn);
this.session.getSessionConfiguration().setOption(ClockTypeOption.get("pseudo"));
this.clock = (PseudoClockScheduler) session.getSessionClock();
this.clock.setStartupTime(clockTime);
droolsIn.close();
System.out.println("read");
}
In my other codes, I set the clock type of session to "pseudo" with a
KnowledgeSessionConfiguration
instance. However, when I serialized it, it's clock type was "realtime". It
seems that the some of session's
fields were not serialized.
So, I wonder are there any other ways to serialize a session? I heard about
XStream, is it appropriate to
serialize a session. And how?
Or, are there methods allowing me to set the clock type of a session to
"pseudo" after deserializing it?
Thank you very much!
--
View this message in context: http://drools.46999.n3.nabble.com/Serialization-issue-with-StateKnowledge...
Sent from the Drools: User forum mailing list archive at Nabble.com.
14 years, 1 month
FireUntilHalt
by crajor
I have a fairly complicated drools program and I want to introduce temporal
reasoning to it. I spent a bit of time writing some proof-of-concept
programs to get the feel of fusion and then tried to slowly introduce things
into my original drools program. When I changed my program from using
fireAllRules() to using fireUntilHalt() on a separate thread, I suddenly get
failures in my unit tests. (My first thought was that there was a race
condition between my unit tests and the thread calling fireUntilHalt() so I
introduced a delay before my unit tests but no luck)
Here are some of the behaviors I am seeing.
1) I occasionally get nullpointerexception from the thread running
fireUntilHalt()
2) My lock-on-active rules aren't firing
I have banged my head on this a while with no success. (I even tried
putting fireAllRules() in a loop because of suggestions I saw but no luck
and same behavior). My questions are, Is there a secret to using
fireUntilHalt() that I am not aware of? Can anybody point me to where I can
educate myself on its proper use?
BTW no persistence and no spring in the code at this point.
Thanks, in advance, for any help you can provide.
Craig
--
View this message in context: http://drools.46999.n3.nabble.com/FireUntilHalt-tp4018610.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
14 years, 1 month
Rule refiring issue !
by abhinay_agarwal
hey all,
i have a scenario like this..
rule "rule1"
agenda-group "1"
salience 0
when
//something
then
setFocus("2")
end
rule "rule1"
agenda-group "1"
salience -1
when
//something
then
//something
end
rule "rule3"
agenda-group "2"
salience 0
when
//something
then
//something
end
when initially my rule 1 gets fired, it executes its work and sets focus on
rule 3....
After the execution of rule 3, when it goes back to agend-group "1"..the
rule 1 is fired again..
can i do something to stop the firing of rule 1 again..i want my rule 2 to
just get fired when the focus is set again to agenda-group "1"..
i have tried using "no-loop" and "lock-on active", but they dont help in my
case !!
thanks,
Abhinay
--
View this message in context: http://drools.46999.n3.nabble.com/Rule-refiring-issue-tp4018618.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
14 years, 1 month
[Solved] Concurrency bug in 5.4.0.Final
by Edson Tirelli
Hi all,
Just a heads up, in case you are using the community release 5.4.0.Final
in a multi-threaded application, be aware that we found a quite serious
racing condition bug:
https://issues.jboss.org/browse/JBRULES-3573
The bug is now fixed in 5.4.x branch, so I strongly recommend that you
build from source and use that instead. The bug was also fixed in the
up-stream branch and will be released in 5.5.0.
IMPORTANT: if you are a Red Hat subscriber, you don't need to do anything
as the problem did not exist in the product release.
Edson
--
Edson Tirelli
JBoss Drools Core Development
JBoss by Red Hat @ www.jboss.com
14 years, 1 month
Issue
by salt
I have two objects vehicles and transactions. I am fetching values of all
transactions from db and using an list and setting in the vehicles object.
for example let have three columns and four rows..
name date price
A 12/07 700
B 12/07 100
D 13/07 100
C 14/07 150
i will be looping like this drools spreadsheet.
$v1:vehicles() transaction() from$v1.transactionList
Now i need to check for C in names and if there is D above to that need to
set true.
SCENARIOS
A,B,C,D,B - for this false needs to be set
A,B,C,D,C - set true
how can we do this in drools spreadsheet
is this possibe.?
--
View this message in context: http://drools.46999.n3.nabble.com/Issue-tp4018604.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
14 years, 1 month