All the cool stuff of JBoss BRMS

5,205 views
5,060 views

Published on

Giovanni Marigi - JBug Roma - January 2012

Published in: Technology, Education
0 Comments
4 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
5,205
On SlideShare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
186
Comments
0
Likes
4
Embeds 0
No embeds

No notes for slide

All the cool stuff of JBoss BRMS

  1. 1. All the cool stuff of JBoss BRMS Giovanni Marigi JBoss Consultant Red Hat, Inc. January 2012 String.class.getName()
  2. 2. Agenda <ul><li>What is a BRMS? BRMS features BRMS benefits
  3. 3. BRMS - Guvnor
  4. 4. BRMS Assets package facts working sets rules decision tables test scenarios other assets
  5. 5. JBPM5 processes
  6. 6. BRMS authoring
  7. 7. Eclipse integration
  8. 8. Rule agents </li></ul>
  9. 9. <ul><li>What is a BRMS? </li></ul><ul><li>BRMS (business rules management system) a software where to define and externalize the business and decision logic used inside programs inside an organization </li></ul>
  10. 10. <ul><li>What is a BRMS? </li></ul><ul><li>BRMS a single platform for business modeling JBoss BRMS includes: Expert : Rule Engine Flow/JBPM5 : Rules Process Management Fusion : Complex Event Processing Guvnor : BRMS “front end” and repository for BRMS artifacts JBoss BRMS is distributed: . war archive . already packaged with an EAP . ready for AS7 </li></ul>
  11. 11. <ul><li>What is a BRMS? </li></ul><ul><li>Every artifact inside a BRMS is an asset
  12. 12. The assets define a knowledge base
  13. 13. Business logic is made by several assets: facts (domain model) rules (of course) business processes (workflows) decision tables functions more...
  14. 14. Not only business rules! </li></ul>
  15. 15. <ul><li>BRMS features </li></ul><ul><li>Centralized repository of business assets
  16. 16. Version control of business assets
  17. 17. IDE/User tools to define and to “governance” the decision logic
  18. 18. Build, deploy, testing of decision logic
  19. 19. Packages of business assets
  20. 20. Categorization of business assets
  21. 21. Roundtrip, integration with dev Tools (Eclipse)
  22. 22. JCR repository (jackrabbit or modeshape) for assets
  23. 23. BRMS can be configured for high availabilty </li></ul>
  24. 24. <ul><li>BRMS benefits </li></ul><ul><li>Logic and data separation
  25. 25. Cross domain logic
  26. 26. Reuse, logic opened to changes
  27. 27. Easy to maintain the business logic
  28. 28. Changes in live systems
  29. 29. Several stakeholders can contribute in defining the business logic (Business Analyst, Rule expert, Developer, Administrators) </li></ul>
  30. 30. <ul><li>BRMS - Guvnor </li></ul><ul><li>Drools Guvnor 5.4.0 Beta1
  31. 31. Drools Guvnor 5.3.0 last stable
  32. 32. Drools Guvnor 5.3.0 includes: Expert 5.3 (rule engine) Fusion 5.3 (CEP) Flow/JBPM5
  33. 33. Eclipse + JBoss Tools </li></ul><ul><li>BRMS 5.2 last stable
  34. 34. BRMS 5.2 includes: - Drools Guvnor 5.2 - Drools Expert 5.2 - Drools Fusion 5.2
  35. 35. BRMS 5.3 (next release) will be based on Guvnor 5.3
  36. 36. JBoss Developer Studio
  37. 37. Bug fixing,patching SLA Enterprise certification | QA </li></ul>
  38. 38. <ul><li>BRMS assets - Package </li></ul><ul>How to start? define a new package for business assets </ul>Guvnor Knowledge base
  39. 39. <ul><li>BRMS assets: Model/Facts </li></ul><ul><li>A package must contain a fact model
  40. 40. fact model != domain model a fact model typically overlaps a domain model but better to make it decouple from the domain model
  41. 41. Rules and assets reason upon a fact model
  42. 42. Two ways to do define your fact model: - upload a JAR file containing Java Classes - declare a model within Guvnor </li></ul>
  43. 43. <ul><li>BRMS assets: Working Sets </li></ul><ul><li>Working sets are groups of facts
  44. 44. Use them to put constraints on a group of facts and restrict the “reasoning domain” of your business rules
  45. 45. Disabled by default </li></ul>
  46. 46. <ul><li>BRMS assets: Rules </li></ul><ul><li>Rules are the “backbone” of a BRMS
  47. 47. Don't use a BRMS if you don't have business rules
  48. 48. Don't use a BRMS if you don't want or you can't separate logic from data
  49. 49. Rules are processed and evaluated by a Rule Engine (Drools Expert)
  50. 50. Forward chaining rule engine which implements the RETE algorithm (ReteOO)
  51. 51. Rich native language to define rules
  52. 52. A rule is contained in a DRL file
  53. 53. More info on Drools Expert: Jbug Italy slideshare site: http://www.slideshare.net/jbugrome </li></ul>
  54. 54. <ul><li>BRMS assets: Rules </li></ul><ul>Forward chaining </ul><ul>Rule Engine </ul>
  55. 55. <ul><li>BRMS assets: Rules </li></ul>rule &quot;Approve if not rejected&quot; salience -100 agenda-group &quot;approval&quot; when not Rejection() p : Policy(approved == false,policyState:status ) exists Driver(age > 25) Process(status == policyState) then log(&quot;APPROVED: due to no objections.&quot;); p.setApproved(true); end <ul><li>Anatomy of a rule </li></ul><ul><li>Example of a rule </li></ul>
  56. 56. <ul><li>BRMS assets: Rules </li></ul><ul><li>Inside BRMS there 4 ways to create a rule: - from scratch,code; can be validated inside BRMS (requires knowledge of Expert) - using the guided editor - uploading a decision table spreadsheet - creating a decision table spreadsheet via the guided editor </li></ul>
  57. 57. <ul><li>BRMS assets: Rules </li></ul><ul><li>Validation of a rule written from scratch </li></ul>
  58. 58. <ul><li>BRMS assets: Rules </li></ul><ul><li>Rules with the guided editor </li></ul>
  59. 59. <ul><li>BRMS assets: Decision Tables </li></ul><ul><li>Express rules with a spreadsheet
  60. 60. A spreadsheet can be imported or created via the guided web editor
  61. 61. A wizard generator for spreadsheet is available in BRMS!
  62. 62. A decision table at runtime is transformed in a series of DRL rules </li></ul>
  63. 63. <ul><li>BRMS assets: Test Scenarios </li></ul><ul><li>Test scenarios are assets used to validate that the rules inside the knowledge base (package) works as expected
  64. 64. A scenario is made by a given section (list of facts and its initial state) and an expect section
  65. 65. What we can “assert” in a expect section? - Rule Validate that a certain rule fired. - Fact value Validate fact values for a fact created in the Given section. -Any fact that matches Validate that there is at least one fact in the knowledge base with the specified field values. </li></ul>
  66. 66. <ul><li>BRMS assets: Test Scenarios </li></ul>
  67. 67. <ul><li>BRMS assets: JBPM5 </li></ul><ul><li>A workflow is a process that describes the order in which a series of steps need to be executed, using a flow chart.
  68. 68. JBPM5 is based on Drools Flow
  69. 69. Workflow guided by rules
  70. 70. Rule workflow is the new “generation” of business workflow
  71. 71. Rules + workflow: dynamic processes </li></ul>
  72. 72. <ul><li>BRMS assets: JBPM5 </li></ul><ul><li>JBPM5 workflow are BPMN2 processes
  73. 73. No legacy xml to define the workflow but a standard!
  74. 74. Human task (human interaction with a flow) The task service implementation is based on the WS-HumanTask (WS-HT) specification
  75. 75. Rule Task: use drools rules inside the flow
  76. 76. Pluggable Service Task (work items): nodes with custom logic (e.g. DBControl, EJBControl, EmailControl)
  77. 77. Gateway (split,converge) the decision in agateway can be taken by a drools rule!
  78. 78. Events (start,end,intermediate)
  79. 79. Timers </li></ul>
  80. 80. <ul><li>BRMS assets: JBPM5 </li></ul><ul><li>BPMN2 editor in Eclipse
  81. 81. BPMN2 editor in BRMS (web editor)
  82. 82. BRMS can upload BPMN2 processes designed with other BPMN2 modeling tool
  83. 83. Online repository to download ready to use service tasks JBPM Service repository
  84. 84. JBPM 3 to 5 migration tool https://github.com/droolsjbpm/jbpmmigration </li></ul>
  85. 85. <ul><li>BRMS assets: JBPM5 </li></ul><ul><li>When defined a new work item is available inside Eclipse </li></ul>
  86. 86. <ul><li>BRMS assets: JBPM5 </li></ul><ul><li>Web Editor integrated inside BRMS (starting from BRMS 5.3) Available in Guvnor 5.3 </li></ul>
  87. 87. <ul><li>BRMS other assets </li></ul><ul><li>Spring context editor to define spring context files;once created they are accessible via HTTP inside the package
  88. 88. DSL functions Define rules in a domain specific language
  89. 89. Enumeration Enum data to be used in rules
  90. 90. Functions
  91. 91. Rule templates </li></ul>
  92. 92. <ul><li>BRMS authoring </li></ul><ul><li>Every asset in BRMS is versioned ; every time an asset changes a new version number is attached
  93. 93. Assets anyway can't be branched or tagged!
  94. 94. An asset contains meta data information
  95. 95. Assets can be categorized
  96. 96. An asset can be linked to many categories
  97. 97. Categories don't have any meaning at runtime; useful to order the assets
  98. 98. An asset can have a status (e.g “Draft”, “Completed”); it's a sort of label </li></ul>
  99. 99. <ul><li>BRMS authoring </li></ul><ul><li>A package otherwise is versioned on demand, taking a snapshot for deployment
  100. 100. Creating a snapshot means that the BRMS package is ready to be used from external application
  101. 101. Before taking a snapshot a build package is required
  102. 102. With a build every assets inside the package is validated
  103. 103. Status and Categories can be used to select only specific assets to include inside a snapshot (Use selector) (e.g. create a snaposhot only with assets belonging to category “Fraud” and with Status “Completed”)
  104. 104. A snapshot will be published inside the repository and accessible via a URL </li></ul>
  105. 105. <ul><li>BRMS authoring </li></ul>
  106. 106. <ul><li>BRMS Eclipse integration </li></ul><ul><li>Eclipse can be configured to import the resources (assets) published in BRMS
  107. 107. Assets can be edited in Eclipse and committed to BRMS (complete roundtrip)
  108. 108. Eclipse gives the capability to compare different version of the same asset
  109. 109. Requires JBoss Developer Studio 4.x or Eclipse 3.6.x + JBoss Tools
  110. 110. File --> Import --> Guvnor --> Resources from Guvnor </li></ul>
  111. 111. <ul><li>BRMS Eclipse integration </li></ul>
  112. 112. <ul><li>BRMS Rule Agent </li></ul><ul><li>How to use a BRMS package inside your application?
  113. 113. Create a Drools RuleAgent able to get (download) its KnowledgeBase from BRMS
  114. 114. Define a change-set.xml (simple xml file) file where the BRMS packages are listed
  115. 115. The KnowledgeBase is the entry point to fire rules, execute bpmn processes,... </li></ul>
  116. 116. <ul><li>BRMS Rule Agent </li></ul><ul>KnowledgeAgent kagent = KnowledgeAgentFactory.newKnowledgeAgent(&quot;MyAgent&quot;, kaconf); kagent.applyChangeSet( ResourceFactory.newClassPathResource(&quot;change-set.xml&quot;));KnowledgeBase kbase = kagent.getKnowledgeBase(); change.set.xml <?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?> <change-set xmlns=&quot; http://drools.org/drools-5.0/change-set &quot; xmlns:xs=&quot; http://www.w3.org/2001/XMLSchema-instance &quot; xs:schemaLocation=&quot;http://drools.org/drools-5.0/change-set http://anonsvn.jboss.org/repos/labs/labs/jbossrules/trunk/drools-api/src/main/resources/change-set-1.0.0.xsd&quot; > <add> <resource source=&quot;http://localhost:8080/guvnor/org.drools.guvnor.Guvnor/package/JBUG/LATEST&quot; type=&quot;PKG&quot; basicAuthentication=&quot;enabled&quot; username=&quot;uid&quot; password=&quot;pwd&quot;/> </add> </change-set> </ul>
  117. 117. <ul><li>BRMS Rule Agent </li></ul>final StatefulKnowledgeSession ksession = kbase.newStatefulKnowledgeSession(); //insert fact instances in kb ksession.insert(new Car(&quot;AudiA4&quot;,4)); ksession.startProcess(&quot;Process1&quot;); ksession.fireAllRules(); ksession.dispose() <ul><li>What to do with a KnowledgeBase? For example start a process and insert some fact instances to be evaluated inside a process RuleTask </li></ul>
  118. 118. <ul><li>BRMS Access BRMS repo </li></ul><ul><li>BRMS repository can also be accessed - REST API - HTTP (WebClient) - WebDAV </li></ul>
  119. 119. <ul><li>BRMS Resources </li></ul><ul><li>http://www.jboss.org/drools/lists
  120. 120. http://www.jboss.org/jbpm/lists
  121. 121. IRC server: irc.codehaus.org
  122. 122. Channels: #drools #guvnor #jbpm </li></ul>THAT'S ALL FOLKS!
  123. 123. All the cool stuff of JBoss BRMS THANKS! [email_address]

×