Building the Enlightened Enterprise 

JBoss BRMS & Fuse Integration Lab

Eric D. Schabell    &    Christina Lin

JBoss BRMS on FUSE

BRMS Rules

Embedded Java 

JavaEE

OSGi

Lab One

Install JBoss Fuse

Download

Install

  • Change to the JBoss Fuse ext directory

    • Go to users.properties file

    • remove the '#' before 

      admin=admin,admin
  • Change to the JBoss Fuse bin directory

  • Start JBoss Fuse by executing 

    • ./fuse

Lab Two

Compile the project

Compile using maven

Lab Three

Simple Rule Example

Running a DRL on OSGi

  • Rule file sample.drl is locate under 
    • src/main/resources/org.drools.example.drink/
      rule "CanDrink"
      when
          p : Person( age >= 21 )
      then
      	p.setCanDrink(true);
      end
  • feel free to change the age 

Adding Feature Location

  • In the JBoss Fuse command console, add the url pointing to the file containing the description of the BRMS/BPM OSGI modules
    • features:addurl mvn:org.drools.example/features/1.0.0-SNAPSHOT/xml/features

Deploy the module 

  •  This module which is a feature will install the code of the bundle simple-rule but also drools core & compiler like kieproject (api & internal)
    • features:install simple-rule
  • You will see that the bundle has been installed and started as the Activator class will report the following message
    • KieSession created.

Running the project

  • Bundle activator class contains the code to create a KieContainer, KieBaseConfiguration & KieBase and will also generate 20 random people to verify if they can Drink according to their age.
Person Young Person aged of 18, can't go to the Bar
Person Old Person aged of 21 , can go to the Bar
Person Old Person aged of 21 , can go to the Bar


Stop Bundle

  • Stop the bundle by 
    • features:uninstall simple-rule 
  • When you stop the bundle simple-rule, the Kie Session is stopped and this message appears in the console of JBoss Fuse
    • KieSession disposed

Lab Four

Externalise the rules assets

Separating Rules and code

  • One of the benefit of an OSGI platform is that the bundles (= jar file + META DATA defined in the MANIFEST.mf file) are isolated form each other as they run within their own classloader

asset-bundle

simple-kie-bundle

Rules

Decision tables

KieBase  KieSessions

Changing DRL in asset bundle

  • Uses the same code as the example "Simple Rule Example" but it has been packaged into 2 bundles.
  • Go to assets-bundle 
    • ​src/main/resources/org.drools.example.drink/ 
      rule "CanDrink"
      when
          p : Person( age >= 21 )
      then
      	p.setCanDrink(true);
      end
  • feel free to change the age 

Adding Feature Location

  • In the JBoss Fuse command console, add the url pointing to the file containing the description of the BRMS/BPM OSGI modules
    • features:addurl mvn:org.drools.example/features/1.0.0-SNAPSHOT/xml/features

Deploy the module 

  •  This module which is a feature will install the code of the bundle simple-rule but also drools core & compiler like kieproject (api & internal)
    • features:install simple-import-rule
  • You will see that the bundle has been installed and started as the Activator class will report the following message
    • KieSession created.

Running the project

  • Bundle activator class contains the code to create a KieContainer, KieBaseConfiguration & KieBase and will also generate 20 random people to verify if they can Drink according to their age.
Person Young Person aged of 18, can't go to the Bar
Person Old Person aged of 21 , can go to the Bar
Person Old Person aged of 21 , can go to the Bar


Stop Bundle

  • Stop the bundle by 
    • features:uninstall simple-import-rule
  • When you stop the bundle simple-import-rule, the Kie Session is stopped and this message appears in the console of JBoss Fuse
    • KieSession disposed

Lab Five

External XLS Decision Table

External Decision Table 

  • JBoss BRMS supports to externalize rules in a XLS Decision Table, this lab externalize the location of the decision table.

Change the location of Decision table

  • Go to FetchExternalResourceOsgiActivator.java
    • Change the location of EXTERNAL_XLS_RESOURCE to your local cheeseDecisionTable.xls
private static final ReleaseId APP_REL_ID = KieServices.Factory.get().newReleaseId("org.drools.example", "fetch-external-resource", "1.0.0-SNAPSHOT");
private static final String EXTERNAL_XLS_RESOURCE = "file:///Users/chmoulli/MyProjects/droolsjbpm-osgi-examples/documentation/decision-table/cheeseDecisionTable.xls";

Adding Feature Location

  • In the JBoss Fuse command console, add the url pointing to the file containing the description of the BRMS/BPM OSGI modules
    • features:addurl mvn:org.drools.example/features/1.0.0-SNAPSHOT/xml/features

Deploy the module 

  •  This module which is a feature will install the code of the bundle simple-rule but also drools core & compiler like kieproject (api & internal)
    • features:install fetch-external-resource
  • You will see that the bundle has been installed and started as the Activator class will report the following message
    • KieSession created.

Running the project

  • Bundle activator class contains the code to create a KieContainer, KieBaseConfiguration & KieBase and after rules calculation, the following result will be displayed
Cheese Cheddar costs 50 EUR.
Cheese Cheddar costs 50 EUR.
Cheese Stilton costs 10 EUR.
Cheese Stilton costs 10 EUR.
Cheese Cheddar costs 50 EUR.
Cheese Cheddar costs 50 EUR.

Stop Bundle

  • Stop the bundle by 
    • features:uninstall fetch-external-resource
  • When you stop the bundle fetch-external-resource, the Kie Session is stopped and this message appears in the console of JBoss Fuse
    • KieSession disposed
  • For later update of the XLS file, the bundle used for this example must be restarted to create new Session and load new Rules definition
    • osgi:restart ID_OF_THE_BUNDLE
Made with Slides.com