KieBaseConfiguration config = KnowledgeBaseFactory.newKnowledgeBaseConfiguration();
config.setOption( EventProcessingOption.CLOUD );
KnowledgeBase kbase = loadKnowledgeBaseFromString( config, str );
StatefulKnowledgeSession ksession = createKnowledgeSession(kbase);
SessionEntryPoint ep = ksession.getEntryPoint( "X" );
ep.insert( new StockTick( 1,
"RHT",
10,
1000 ) );
int rulesFired = ksession.fireAllRules();
assertEquals( 0,
rulesFired );
org.kie.api.definition.type.FactType event = kbase.getFactType( "org.drools.cloud",
"Event" );
Object e1 = event.newInstance();
event.set( e1,
"name",
"someKey" );
event.set( e1,
"value",
"someValue" );
ep.insert( e1 );
rulesFired = ksession.fireAllRules();
assertEquals( 1,
rulesFired );
// let some time be spent
Thread.currentThread().sleep( 1000 );
// check both events are still in memory as we are running in CLOUD mode
assertEquals( 2,
ep.getFactCount() );
}