Business Rule – doesn’t fire

Home Page › Forums › BizTalk 2004 – BizTalk 2010 › Business Rule – doesn’t fire

Viewing 1 reply thread
  • Author
    Posts
    • #21922

      I’m creating a video series on Business Rules.  Sometimes the “simplest” things don’t work. I’ve done a lot with rules in the last year, but not with the database.

      I took the “Loans Processing using Business Rules” example from the SDK.
      I was trying to show how a database vocabulary worked.  So instead of “hard-coding” the minimum months a person lives at the current residence into the rules, I put in a vocabulary, which in theory, will get the value from a table. 

      I created a table in Northwind database called “BusinessRuleParms’.  I didn’t put any key or id field on it (I was debating that when I created).  So it’s a singleton – should only be one row stored (and there is only one now).

      I created two columns in the table MininumTimeInResidence and MinimumTimeOnJob, each an integer field.   I also created XML/element vocab called MonthsInCurrentResident.  So I changed the two rules in the SDK to use my vocabulary fields.  All the other three status fields get set, but neither “Residencey Status Rule” and “Negation of Residency Status Rule” fire.

      Any ideas what I am doing wrong?

      Thanks,
      Neal

       

       

       

    • #21924

      Also, since I haven’t used database with rules, I’m confused about a few related items:

      1) The sample (SDK\Business Rules\Loans Processing using Business Rules) has a c# project called “MyFactRetriever”.  The setup deploys it, but I cannot see where it is actually used.

        This page documents this module of the SDK, mentions that fact retriever, but again, doesn’t say how or where it is used.

      http://msdn.microsoft.com/en-us/library/aa559727.aspx

       

      2) I exported the policy file to BRL/xml file using the Deploy wizard so I can look at it.

      I found this line:

       <datarow ref=”db_33″ server=”BIZTALK-D3W3PVB\Northwind” dataset=”Northwind” table=”BusinessRuleParms” instances=”16″ selectivity=”1″ isdataconnection=”true” instance=”0″ />

      So if I hard-codes my computer name as the database server, how does one switch to a different server when you migrate to QA or PROD machine?

      Thanks,

      Neal

      • #21929

        Ok, I think I figured it out.  It’s the custom fact retriever that both sets the database connection and retrieves the data, inserting the Microsoft.RuleEngine.DataConnection object into the rule engine.

        Here is some of the code from the MyFactRetriever.  I finally read more books, and figured out that the fact retriever is specified as a property on the Policy/version.  I was having trouble before, because I couldn’t really see where the FactRetriever was used or called.

         

                    SqlConnection con1 = new SqlConnection(“Initial Catalog=Northwind;Data Source=(local);Integrated Security=SSPI;”);

                    DataConnection dc1 = new DataConnection(“Northwind”, “CustInfo”, con1);
                    engine.Assert(dc1);

        // I added the next two lines of code so that my new table would be “asserted”
        // (My new table name = BusinessRuleParms)

                   DataConnection dc2 = new DataConnection(“Northwind”, “BusinessRuleParms”, con1);
                    engine.Assert(dc2);

         

        Neal

Viewing 1 reply thread
  • The forum ‘BizTalk 2004 – BizTalk 2010’ is closed to new topics and replies.