[rules-users] Drools 6.0.1 CEP stucks during marshaling in fireUntilHalt mode
ters
ters at ukr.net
Tue Mar 4 12:37:02 EST 2014
Hi drools experts.
We use drools fusion complex event processor (CEP). After migration from
5.4.0 to 6.0.1 I encountered a problem - CEP stucks during marshaling in
fireUntilHalt mode. Below self-contained reproducer.
--------------------------------
/*Event class:*
/public class Test1 {
private Date timestamp;
private String id;
}/
/*Rule drl:*
/package bpmn;
import com.test.event.*;
dialect "mvel"
declare BusinessProcessName
name : String;
end
declare com.test.event.Test1
@role( event )
end
rule "Insert Business Process Name"
salience 10
when
not BusinessProcessName(name == "SomeName")
then
System.out.println("Insert Business Process Name");
insert(new BusinessProcessName("SomeName"));
end
rule "Start event1"
when
$event1 : Test1()
then
System.out.println("Start event1 fired.");
end/
/*Test with whole initialization*
/public class TestDrools6CEPDeadLock implements RuleRuntimeEventListener {
private KieSession ksession;
private Marshaller marshaller;
@Test
public void test1() throws Exception {
initSession();
runFireUntilHaltThread();
System.out.println("-= 1 =-");
ksession.insert(new Test1());
System.out.println("-= 2 =-");
ksession.insert(new Test1());
}
private void runFireUntilHaltThread() {
new Thread(new Runnable() {
public void run() {
ksession.fireUntilHalt();
}
}).start();
}
private void initSession() {
KnowledgeBuilder kbuilder =
KnowledgeBuilderFactory.newKnowledgeBuilder();
kbuilder.add(ResourceFactory.newClassPathResource("TestDrools6CEPDeadLock.drl"),
ResourceType.DRL);
if (kbuilder.hasErrors()) throw new RuntimeException("Unable to
compile drl\".");
KieBaseConfiguration config =
KieServices.Factory.get().newKieBaseConfiguration();
config.setOption(EventProcessingOption.STREAM);
KnowledgeBase kbase = KnowledgeBaseFactory.newKnowledgeBase(config);
kbase.addKnowledgePackages(kbuilder.getKnowledgePackages());
ksession = kbase.newKieSession();
ksession.addEventListener((RuleRuntimeEventListener) this);
marshaller = MarshallerFactory.newMarshaller(kbase);
}
@Override
public void objectInserted(ObjectInsertedEvent event) {
System.out.println("------------------objectInserted---------------");
marshallSession();
}
@Override
public void objectUpdated(ObjectUpdatedEvent event) {
System.out.println("------------------objectUpdated---------------");
marshallSession();
}
@Override
public void objectDeleted(ObjectDeletedEvent event) {
System.out.println("------------------objectDeleted---------------");
marshallSession();
}
private void marshallSession() {
try {
marshaller.marshall(new ByteArrayOutputStream(), ksession);
System.out.println("------------------marshalled---------------");
} catch (IOException e) {
e.printStackTrace();
}
}
}/
*Output *of test I see only:
>-= 1 =-
>------------------objectInserted---------------
>Insert Business Process Name
Further engine hangs up, looks like dead lock on
ProtobufOutputMarshaller.evaluateRuleActivations() (line 256) >
RuleExecutor.reEvaluateNetwork().
Notes:
1) It worked fine on 5.4.0.Final version
2) Current problem not occurs if I run fireAllRules in second thread instad
of filreUntilHalt
private void runFireAllRulesInThread() {
new Thread(new Runnable() {
public void run() {
while(true){
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
LOG.error(e);
}
synchronized (ksLock){
ksession.fireAllRules();
}
}
}
}).start();
}
I need this thread to ensure firing timing rules such like:
$event1 : Test1();
not Test2(this after[0s, 10s ] $event1 );
I hope this can help to resolve either my or drools bug.
Thanks in advance.
--
View this message in context: http://drools.46999.n3.nabble.com/Drools-6-0-1-CEP-stucks-during-marshaling-in-fireUntilHalt-mode-tp4028493.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
More information about the rules-users
mailing list