Show Table of Contents
26.2. Number Guess Example: Starting the RuleFlow
final StatefulKnowledgeSession ksession = kbase.newStatefulKnowledgeSession(); KnowledgeRuntimeLogger logger = KnowledgeRuntimeLoggerFactory.newFileLogger(ksession, "log/numberguess"); ksession.insert( new GameRules( 100, 5 ) ); ksession.insert( new RandomNumber() ); ksession.insert( new Game() ); ksession.startProcess( "Number Guess" ); ksession.fireAllRules(); logger.close(); ksession.dispose();
- The above code demonstrates the creation of the package and the loading of the rules (using the
add()method). - There is an additional line to add the Rule Flow (
NumberGuess.rf), which provides the option of specifying different rule flows for the same Knowledge Base. - Once the Knowledge Base is created it can be used to obtain a Stateful Session. The facts are then inserted.

Where did the comment section go?
Red Hat's documentation publication system recently went through an upgrade to enable speedier, more mobile-friendly content. We decided to re-evaluate our commenting platform to ensure that it meets your expectations and serves as an optimal feedback mechanism. During this redesign, we invite your input on providing feedback on Red Hat documentation via the discussion platform.