"then\n" +
" modify($b) { setOn(true) }\n" +
" if (counter.incrementAndGet() > 10) throw new RuntimeException();\n" +
"end\n";
KnowledgeBuilderConfiguration config = KnowledgeBuilderFactory.newKnowledgeBuilderConfiguration();
config.setOption(PropertySpecificOption.ALWAYS);
KnowledgeBase kbase = loadKnowledgeBaseFromString( config, rule );
StatefulKnowledgeSession ksession = kbase.newStatefulKnowledgeSession();
AtomicInteger counter = new AtomicInteger(0);
ksession.setGlobal( "counter", counter );