Hello,
I have given it a try with JBoss Rules 4.0.0 and this time, both facts
are retracted! Congratulations for this exciting new version.
Regards,
Alexandre
On 5/24/07, A Gattiker <agattik(a)gmail.com> wrote:
Hello,
I am trying to use assertLogical in combination with a
WorkingMemoryEventListener in order to have business rules drive my
application: if conditions, then do something; if conditions not true
anymore, then do something else.
However, it seems that if the rule is activated multiple times, then
becomes unsupported, only one of the assertLogical'ed facts is
retracted, as illustrated in the example below.
Does anyone know how to get around that problem? I thought
assertLogical would be an elegant solution but maybe there is a better
way?
Kind regards
Alexandre
To reproduce the problem: With the JBoss Rules 3.0.6 IDE, I have
started with a test project with the Eclipse Wizard and modified it as
listed below. "Date" facts are used simply to ensure unequality.
DRL:
import com.sample.DroolsTest.Message;
import java.util.Date;
rule "Hello World"
when
$i : Message ( status > 4 )
then
assertLogical(new Date());
end
Java:
workingMemory.addEventListener(new
DebugWorkingMemoryEventListener());
Message message = new Message();
message.setStatus( 10 );
FactHandle fh = workingMemory.assertObject( message );
workingMemory.fireAllRules();
Thread.sleep(2000);
message.setStatus( 6 );
workingMemory.modifyObject(fh, message);
workingMemory.fireAllRules();
Thread.sleep(2000);
message.setStatus( 2 );
workingMemory.modifyObject(fh, message);
workingMemory.fireAllRules();
Output:
[ObjectAsserted: handle=[fid:1:1];
object=com.sample.DroolsTest$Message@629da7ee]
[ObjectAsserted: handle=[fid:2:2]; object=Thu May 24 19:19:01 CEST 2007]
[ObjectModified: handle=[fid:1:3];
old_object=com.sample.DroolsTest$Message@629da7ee;
new_object=com.sample.DroolsTest$Message@629da7ee]
[ObjectAsserted: handle=[fid:3:4]; object=Thu May 24 19:19:03 CEST 2007]
[ObjectModified: handle=[fid:1:5];
old_object=com.sample.DroolsTest$Message@629da7ee;
new_object=com.sample.DroolsTest$Message@629da7ee]
[ObjectRetracted: handle=[fid:3:4]; old_object=Thu May 24 19:19:03 CEST 2007]