Friday, July 13, 2007

Discount insurance brokers example for BRMS (Fernando Meyer)

There is a new BRMS example available. It is written up in the manual as a tutorial, but the information is repeated here. We are having some issues with our build server - so the docs available in the snapshots are probably not as up to date as the source is.



-------------
Fernando runs a dodgy fly by night insurance operation in Sao Paulo, Brasil. These are his rules - would you buy insurance from him ? (I wouldn't).





This example takes you through the key steps in using the BRMS with an example respository, and using rules in a very very simple application (which you can use as a basis for your applications).
  • Download the latest version of BRMS from http://cruisecontrol.jboss.com/cc/artifacts/jboss-rules
  • Deploy BRMS WAR file into JBoss4.2 AS or JBossWeb, other containers can be used as well (possibly with some tweaking of dependencies).
  • Check you can access and run the BRMS.
  • Check out the demo project from the Drools subversion repository (this will be included in future distributions): http://anonsvn.labs.jboss.com/labs/jbossrules/trunk/drools-examples/drools-examples-brms/
  • Import the demo business rules insurance repository file into BRMS, the compressed can be found at "files" folder in the demo project.
    • To do this, open the "files" directory, unzip the file there locally, and then go to the "Admin" section and "Manage backups" of the BRMS, select the file, and press "Import" - follow instructions.
  • Navigate through the BRMS web application to see how things are placed and organized and try to create some rules.
  • Go to the "Packages" feature and build the package (you should see no errors).
  • Now go to the "Deployment" feature, when you click on the package, it will show you one snapshot (which was part of the import, you can create more if you like from the previous step).
    • Open a snapshot.
    • Copy the snapshot url that is displayed.
    • Locate the file brmsdeployedrules.properties
    • Place the copied URL in the brmsdeployedrules.properties file.
    • OPTIONAL: To use a file or directory deployment in the rule agent just update brmsdeployedrules.properties according the documentation.
  • Import the example project into eclipse and execute the MainClass. The program will show the following trace (and away you go !):

    RuleAgent(insuranceconfig) INFO (Thu Jul 12 20:06:02 BRT 2007): Configuring with newInstance=true, secondsToRefresh=30

    RuleAgent(insuranceconfig) INFO (Thu Jul 12 20:06:02 BRT 2007): Configuring package provider : URLScanner monitoring URLs: http://localhost:8080/drools-jbrms/org.drools.brms.JBRMS/package/org.acme.insurance/fmeyer With local cache dir of /Users/fernandomeyer/projects/jbossrules/drools-examples/drools-examples-brms/cache

    RuleAgent(insuranceconfig) INFO (Thu Jul 12 20:06:02 BRT 2007): Applying changes to the rulebase. RuleAgent(insuranceconfig) INFO (Thu Jul 12 20:06:02 BRT 2007): Creating a new rulebase as per settings.

    RuleAgent(insuranceconfig) INFO (Thu Jul 12 20:06:02 BRT 2007): Adding package called org.acme.insurance

    APPROVED: due to no objections.
    APPROVED: Driver is safe and mature.
    APPROVED: due to no objections.
    REJECTED: Too many accidents

    The Rule Agent will pick up any changes that happen automatically - as soon as you create a new snapshot of the rules you want to deploy.

16 comments:

  1. I try this on tomcat and i have the next output:

    RuleAgent(insuranceconfig) INFO (Thu Jul 19 11:35:15 CEST 2007): Configuring with newInstance=true, secondsToRefresh=30

    RuleAgent(insuranceconfig) INFO (Thu Jul 19 11:35:15 CEST 2007): Configuring package provider : URLScanner monitoring URLs: http://localhost:8080/drools-jbrms/org.drools.brms.JBRMS/package/org.acme.insurance/InsuranceSnapshot with local cache dir of D:\workspace2\drools-example-brms\cache

    RuleAgent(insuranceconfig) WARNING (Thu Jul 19 11:35:15 CEST 2007): Falling back to local cache.
    java.lang.NullPointerException

    ReplyDelete
  2. I too tried the same example and was getting the following exception :-
    RuleAgent(insuranceconfig) INFO (Tue Jul 24 15:37:23 EDT 2007): Configuring with newInstance=true, secondsToRefresh=30
    RuleAgent(insuranceconfig) INFO (Tue Jul 24 15:37:23 EDT 2007): Configuring package provider : URLScanner monitoring URLs: http://localhost:8080/drools-jbrms/org.drools.brms.JBRMS/package/org.acme.insurance/fmeyer with local cache dir of C:\Vinu\Workspace_V3.3\drools-example-brms\cache
    RuleAgent(insuranceconfig) WARNING (Tue Jul 24 15:37:24 EDT 2007): Falling back to local cache.
    java.lang.NullPointerException
    at org.drools.agent.FileScanner.readPackage(FileScanner.java:104)
    at org.drools.agent.FileScanner.getChangeSet(FileScanner.java:79)
    at org.drools.agent.FileScanner.loadPackageChanges(FileScanner.java:57)
    at org.drools.agent.URLScanner.loadPackageChanges(URLScanner.java:93)
    at org.drools.agent.RuleAgent.checkForChanges(RuleAgent.java:297)
    at org.drools.agent.RuleAgent.refreshRuleBase(RuleAgent.java:265)
    at org.drools.agent.RuleAgent.configure(RuleAgent.java:251)
    at org.drools.agent.RuleAgent.init(RuleAgent.java:183)
    at org.drools.agent.RuleAgent.newRuleAgent(RuleAgent.java:192)
    at org.acme.insurance.launcher.InsuranceBusiness.loadRuleBase(InsuranceBusiness.java:26)

    There was a change made to the local cache dir to point to the local directory.

    It would be great if you can reply to this post..

    Thanks,
    Vinumes

    ReplyDelete
  3. please use the mailing lists for technical help.

    ReplyDelete
  4. The link to the demo is no longer available. http://anonsvn.labs.jboss.com/labs/jbossrules/trunk/drools-examples/drools-examples-brms/ returns 404

    Can you help?

    ReplyDelete
  5. As the link says please use the mailing list for questions on getting the example running. The example is now bundled with the standalone BRMS, there is a README in the download which details how to install the example repository in the BRMS.

    ReplyDelete
  6. I still wonder why using GWT instead of Seam-JSF. Any specific reason?

    ReplyDelete
  7. We do use Seam with GWT, in fact Michael Neale wrote the Seam integration. We chose GWT as it provides a much richer and more scalable environment for Rich Client Applications.

    ReplyDelete
  8. Just out of curiosity. Wouldn't it be better to use your own portfolio (Seam-JSF-RichFaces) to reuse & boost these projects. Furthermore to find/create components which can be also used for the JBoss Admin View or similar?

    I have to admit I personally don't like (or even hate) the "closed src-compiler" of GWT.

    Just giving some thoughts. No offense meant.

    ReplyDelete
  9. no, I don't subscribe to "eating your own dog food" - we use the best tech regardless. Doing what we have done with GWT would just be too hard with JSF, not forgetting the fact that current JSF implementations simple doesn't scale well for complex apps, the sites bog down quickly.

    ReplyDelete
  10. Hmm is that you Burr posting anonymously? ;)

    N.B. Burr is our Product Manager and king promoter of "eating your own dog food" :)

    ReplyDelete
  11. No I'm not Burr. Even though I would love to be to kick your ass for choosing GWT. *scnr* ;)

    Simply trying to understand why someone would choose a closed src tool for such a project, especially when they have something "similar" in their portfolio.

    But I got your points. Thanks for sharing your opinions and answering that fast.

    ReplyDelete
  12. Google open sourced all of the GWT components ages ago, it just did it in a phased fashion:
    Google Web Toolkit Goes Fully Open Source

    ReplyDelete
  13. These are the great blogs; I assure you that I really enjoyed a lot in readingmaryland home owner insurance

    ReplyDelete
  14. I’m definitely coming again to see these articles and blogs.life insurance comparison site

    ReplyDelete
  15. Nice answers in replace of the question with real point of view and explaining about that.gettysurg car insurance

    ReplyDelete
  16. congratulations guys, quality information you have given!!! cheaplifeinsurance

    ReplyDelete