19.4. HelloWorld Example: Execution

final Message message = new Message();
message.setMessage("Hello World");
message.setStatus(Message.HELLO);
ksession.insert(message);

ksession.fireAllRules();

logger.close();

ksession.dispose();
  • A single Message object is created with the message text "Hello World" and the status HELLO and then inserted into the engine, at which point fireAllRules() is executed.
  • All network evaluation is done during the insert time. By the time the program execution reaches the fireAllRules() method call the engine already knows which rules are fully matches and able to fire.

Note

To execute the example as a Java application:
  1. Open the class org.drools.examples.helloworld.HelloWorldExample in your Eclipse IDE.
  2. Right-click the class and select Run as... and then Java application