5 Replies Latest reply on Apr 8, 2008 11:44 AM by mfrossi.mfrossi.gmail.com

    BRMS Integration Question

    mdesignz

      Hello, I have a Seam application that makes use of Drools, and I'd like to migrate it to use Drools' BRMS.  The documentation says to include something like this in components:



      <drools:rule-agent name="insuranceRules"
      url="http://localhost:8080/drools-jbrms/org.drools.brms.JBRMS/package/org.acme.insurance/local-cache-dir="/Users/fernandomeyer/projects/jbossrules/drools-examples/drools-examples-poll="30"
      configuration-name="insuranceconfig" />
      



      but it's not clear to me if there should also be an entry for the working memory reference that gets injected in the code.  Is there a complete working example or write-up anywhere?
      Thanks.

        • 1. Re: BRMS Integration Question
          gavin.king

          Yes, you will also need to config the WorkingMemory.

          • 2. Re: BRMS Integration Question
            mdesignz

            Gavin, thank you for the reply.  It's the syntax of configuring the WorkingMemory that isn't clear to me. In my current application (without BRMS) I have:



                 <drools:rule-base name="applicationScoringRules" rule-files="genericAppScoring.drl"/>
                 <drools:managed-working-memory name="applicationScoringWorkingMemory" auto-create="true" rule-base="#{applicationScoringRules}"/>
            
            



            And then my Seam component makes reference to applicationScoringWorkingMemory.   Switching to use BRMS, the rule-file reference in the rule-base tag would seemingly go away, and I don't see an obvious way to associate the drools:rule-agent with either the drools:rule-base or the drools:managed-working-memory tags.  The Drools examples show doing something like this:


               private static RuleBase loadRuleBaseFromRuleAgent() 
               {
                   RuleAgent agent = RuleAgent.newRuleAgent( "/brmsdeployedrules.properties" );
                   
                   RuleBase rulebase = agent.getRuleBase();
                   StatefulSession session = rulebase.newStatefulSession();
                   session.startProcess(null);
                   
                   return rulebase;
               }
            from within the Java code which makes sense to me, but would be in conflict with injecting the WorkingMemory in the Seam component.
            
            I think I'm missing how to connect the rule-agent reference to the managed-working-memory.   Thanks again for all of your help.
            
            



            • 3. Re: BRMS Integration Question
              mdesignz

              I would be extremely grateful if someone could post an example of using BRMS from within Seam.  See the above for details.  It's still not obvious to me how to make the connection between the rule-agent and either the rule-base or managed-working-memory.  Sorry for being slow.


              • 4. Re: BRMS Integration Question
                mdesignz

                Got it working.  For those that may encounter similar confusion, you need to do the following:



                1. Insert a rule-agent tag in your components.xml file.  The name value is important since it is referenced by the rule base and the working memory.


                2. Insert a managed-working-memory tag in your components.xml file.  The name you specify here, will be the name injected in your Seam component.   Set auto-create to true.


                In the Seam component you want to inject the WorkingMemory (using the same name you specified in the components.xml file), AND you want to inject a RuleBase using the same name as what you specified for the rule-agent in the components.xml file.   This is where I was going off into the weeds.  The injected value is actually a RuleBase object (not a RuleAgent).


                There may be alternate ways of doing this, but this approach worked for me. 

                • 5. Re: BRMS Integration Question
                  mfrossi.mfrossi.gmail.com

                  Hi Robert, I am into Seam - BRMS - JBPM integration as well, would you mind to paste here the portion of your components.xml regarding  drools? Is there a way to use a ruleAgent instead of workingManager into JBPM task as reported in Seam docs?



                   <transition name="approved" to="ship">
                          <action class="org.jboss.seam.drools.DroolsActionHandler">
                              <workingMemoryName>shippingRulesWorkingMemory</workingMemoryName>
                              <assertObjects>
                                  <element>#{customer}</element>
                                  <element>#{order}</element>
                                  <element>#{order.lineItems}</element>
                              </assertObjects>
                          </action>
                      </transition>
                  


                  Thank you