locked
Biztalk Bre conditions met but rules not fired RRS feed

  • Question

  • Schema is generated using BusinessObjectModel(new proj in a solution)

    Data entity

    Namespace Entity
        Public Class Class1Ent
            Dim Names As String = String.Empty
            Dim Ages As Integer = 0
            Public Property Name() As String
                Get
                    Return Names
                End Get
                Set(ByVal value As String)
                    Names = value
                End Set
            End Property
            Public Property Age() As Integer
                Get
                    Return Ages
                End Get
                Set(ByVal value As Integer)
                    Ages = value
                End Set
            End Property
        End Class
        Public Class class2Ent
            Dim Year As Integer
            Dim months As Integer
            Public Property Years() As Integer
                Get
                    Return Year
                End Get
                Set(ByVal value As Integer)
                    Year = value
                End Set
            End Property
            Public Property month() As Integer
                Get
                    Return months
                End Get
                Set(value As Integer)
                    months = value
                End Set
            End Property
        End Class
    End Namespace
    BusinessObjectModel(new proj in a solution):

    Imports SampleBREForMultipleclasses.Entity
    Namespace BOM
        Public Class main
            Private inp() As Class1
            Private inp2() As class2
            Public Property inps() As Class1()
                Get
                    Return inp
                End Get
                Set(ByVal value As Class1())
                    inp = value
                End Set
            End Property
            Public Property inps2() As class2()
                Get
                    Return inp2
                End Get
                Set(ByVal value As class2())
                    inp2 = value
                End Set
            End Property
        End Class
        Public Class Class1
            Private mainnam As New Class1Ent
            Public Property name() As String
                Get
                    Return mainnam.Name
                End Get
                Set(ByVal value As String)
                    mainnam.Name = value
                End Set
            End Property
            Public Property Age() As Integer
                Get
                    Return mainnam.Age
                End Get
                Set(ByVal value As Integer)
                    mainnam.Age = value
                End Set
            End Property
        End Class
        Public Class class2
            Private mainnam As New class2Ent
            Public Property Years() As Integer
                Get
                    Return mainnam.Years
                End Get
                Set(ByVal value As Integer)
                    mainnam.Years = value
                End Set
            End Property
            Public Property month() As Integer
                Get
                    Return mainnam.month
                End Get
                Set(ByVal value As Integer)
                    mainnam.month = value
                End Set
            End Property
        End Class
    End Namespace
    xsd:(generated using BOM):

      <?xml version="1.0" encoding="utf-16" ?>
    - <xs:schema xmlns:b="http://schemas.microsoft.com/BizTalk/2003" elementFormDefault="qualified"xmlns:xs="http://www.w3.org/2001/XMLSchema">
      <xs:element name="main" nillable="true" type="main" />
    - <xs:complexType name="main">
    - <xs:sequence>
      <xs:element minOccurs="0" maxOccurs="1" name="inps" type="ArrayOfClass1" />
      <xs:element minOccurs="0" maxOccurs="1" name="inps2" type="ArrayOfClass2" />
      </xs:sequence>
      </xs:complexType>
    - <xs:complexType name="ArrayOfClass1">
    - <xs:sequence>
      <xs:element minOccurs="0" maxOccurs="unbounded" name="Class1" nillable="true" type="Class1" />
      </xs:sequence>
      </xs:complexType>
    - <xs:complexType name="Class1">
    - <xs:sequence>
      <xs:element minOccurs="0" maxOccurs="1" name="name" type="xs:string" />
      <xs:element minOccurs="1" maxOccurs="1" name="Age" type="xs:int" />
      </xs:sequence>
      </xs:complexType>
    - <xs:complexType name="ArrayOfClass2">
    - <xs:sequence>
      <xs:element minOccurs="0" maxOccurs="unbounded" name="class2" nillable="true" type="class2" />
      </xs:sequence>
      </xs:complexType>
    - <xs:complexType name="class2">
    - <xs:sequence>
      <xs:element minOccurs="1" maxOccurs="1" name="Years" type="xs:int" />
      <xs:element minOccurs="1" maxOccurs="1" name="month" type="xs:int" />
      </xs:sequence>
      </xs:complexType>
      <xs:element name="Class1" nillable="true" type="Class1" />
      <xs:element name="class2" nillable="true" type="class2" />
      </xs:schema>
    Rules:
    AND

    <?xml version="1.0" encoding="utf-8"?>
    <brl xmlns="http://schemas.microsoft.com/businessruleslanguage/2002">
      <ruleset name="A1">
        <version major="1" minor="3" description="" modifiedby="MSRA\bthota" date="2015-05-01T08:49:40.6078696-04:00" />
        <configuration />
        <bindings>
          <xmldocument ref="xml_33" doctype="BOM" instances="16" selectivity="1" instance="0">
            <selector>/</selector>
            <schema>C:\Program Files (x86)\Microsoft Visual Studio 12.0\BOM.xsd</schema>
          </xmldocument>
          <xmldocument ref="xml_32" doctype="BOM.class2" instances="16" selectivity="1" instance="0">
            <selector>/*[local-name()='class2' and namespace-uri()='']</selector>
            <selectoralias>/class2</selectoralias>
            <schema>C:\Program Files (x86)\Microsoft Visual Studio 12.0\BOM.xsd</schema>
          </xmldocument>
          <xmldocument ref="xml_31" doctype="BOM.Class1" instances="16" selectivity="1" instance="0">
            <selector>/*[local-name()='Class1' and namespace-uri()='']</selector>
            <selectoralias>/Class1</selectoralias>
            <schema>C:\Program Files (x86)\Microsoft Visual Studio 12.0\BOM.xsd</schema>
          </xmldocument>
        </bindings>
        <rule name="Rule1" priority="10" active="true">
          <if>
            <and>
              <compare operator="equal">
                <vocabularylink uri="3f0e9bcc-6212-4e6a-853c-e517f157a626" element="05703dd9-1111-40b8-890d-ad7bfc45a925" />
                <lhs>
                  <function>
                    <xmldocumentmember xmldocumentref="xml_31" type="string" sideeffects="false">
                      <field>*[local-name()='name' and namespace-uri()='']</field>
                      <fieldalias>name</fieldalias>
                    </xmldocumentmember>
                  </function>
                </lhs>
                <rhs>
                  <constant>
                    <string>Vinay</string>
                  </constant>
                </rhs>
              </compare>
              <compare operator="not equal">
                <vocabularylink uri="3f0e9bcc-6212-4e6a-853c-e517f157a626" element="c22af575-9920-417c-a545-67fa0ece9832" />
                <lhs>
                  <function>
                    <xmldocumentmember xmldocumentref="xml_31" type="int" sideeffects="false">
                      <field>*[local-name()='Age' and namespace-uri()='']</field>
                      <fieldalias>Age</fieldalias>
                    </xmldocumentmember>
                  </function>
                </lhs>
                <rhs>
                  <constant>
                    <int>31</int>
                  </constant>
                </rhs>
              </compare>
            </and>
          </if>
          <then>
            <function>
              <xmldocumentmember xmldocumentref="xml_31" type="int" sideeffects="true">
                <field>*[local-name()='Age' and namespace-uri()='']</field>
                <fieldalias>Age</fieldalias>
                <argument>
                  <constant>
                    <int>31</int>
                  </constant>
                </argument>
              </xmldocumentmember>
            </function>
            <function>
              <xmldocumentmember xmldocumentref="xml_32" type="int" sideeffects="true">
                <field>*[local-name()='Years' and namespace-uri()='']</field>
                <fieldalias>Years</fieldalias>
                <argument>
                  <constant>
                    <int>32</int>
                  </constant>
                </argument>
              </xmldocumentmember>
            </function>
            <update>
              <vocabularylink uri="aee857f2-09d5-4615-a96c-87041791ec42" element="57517cc6-6bb7-46eb-99eb-a1fdddd5d2f6" />
              <object>
                <reference>
                  <xmldocumentref ref="xml_33" />
                </reference>
              </object>
            </update>
          </then>
        </rule>
        <rule name="Rule2" priority="0" active="true">
          <if>
            <and>
              <compare operator="equal">
                <vocabularylink uri="3f0e9bcc-6212-4e6a-853c-e517f157a626" element="05703dd9-1111-40b8-890d-ad7bfc45a925" />
                <lhs>
                  <function>
                    <xmldocumentmember xmldocumentref="xml_32" type="int" sideeffects="false">
                      <field>*[local-name()='Years' and namespace-uri()='']</field>
                      <fieldalias>Years</fieldalias>
                    </xmldocumentmember>
                  </function>
                </lhs>
                <rhs>
                  <constant>
                    <int>32</int>
                  </constant>
                </rhs>
              </compare>
              <compare operator="not equal">
                <vocabularylink uri="3f0e9bcc-6212-4e6a-853c-e517f157a626" element="c22af575-9920-417c-a545-67fa0ece9832" />
                <lhs>
                  <function>
                    <xmldocumentmember xmldocumentref="xml_32" type="int" sideeffects="false">
                      <field>*[local-name()='month' and namespace-uri()='']</field>
                      <fieldalias>month</fieldalias>
                    </xmldocumentmember>
                  </function>
                </lhs>
                <rhs>
                  <constant>
                    <int>322</int>
                  </constant>
                </rhs>
              </compare>
            </and>
          </if>
          <then>
            <function>
              <xmldocumentmember xmldocumentref="xml_32" type="int" sideeffects="true">
                <field>*[local-name()='month' and namespace-uri()='']</field>
                <fieldalias>month</fieldalias>
                <argument>
                  <constant>
                    <int>322</int>
                  </constant>
                </argument>
              </xmldocumentmember>
            </function>
            <update>
              <vocabularylink uri="aee857f2-09d5-4615-a96c-87041791ec42" element="57517cc6-6bb7-46eb-99eb-a1fdddd5d2f6" />
              <object>
                <reference>
                  <xmldocumentref ref="xml_33" />
                </reference>
              </object>
            </update>
            <halt>
              <vocabularylink uri="aee857f2-09d5-4615-a96c-87041791ec42" element="b8d475d6-c1cd-46d1-bd44-5b91f2ac4eee" />
              <clearagenda>
                <constant>
                  <vocabularylink uri="5e19cad8-b5f1-4f77-93fd-5210c3e45394" element="b28191b6-5401-4782-a1a4-627df6369743" />
                  <boolean>false</boolean>
                </constant>
              </clearagenda>
            </halt>
          </then>
        </rule>
      </ruleset>
    </brl>

    Problem here is:

    Conditions are met when i am sending the input values(direct xml test and also using API)

    but the values are not assigned to output. 

    static support is already there in regedit.

    Thanks for the help.




    • Edited by bvinay Friday, May 1, 2015 1:35 PM
    Friday, May 1, 2015 1:33 PM

Answers

  • Well the rules work now.

    1. StaticSupport to 1 in regedit, ruleengine.exe.config and BTSNTSvc.exe

    2. Document type was given wrong when rule was neither validated nor executed.

    Once the rules are evaluated and rules not fired,

    3. The Type for the root was system.string(need to be microsoft.ruleengine.typedxmldocument)

    4. Issue was that i was updating the Class instead of class1 and class2. updating the right root node.

    Thanks for the help Rene.


    • Edited by bvinay Tuesday, May 5, 2015 8:56 PM 3.
    • Marked as answer by Angie Xu Wednesday, May 13, 2015 8:22 AM
    Tuesday, May 5, 2015 8:53 PM

All replies

  • Hi,

    You are using the Halt function in your second rule, this will cause the execution to halt and the facts are retracted.

    Can you post the tracking of the policy execution?

    Regards,

    René

    Friday, May 1, 2015 1:50 PM
  • Thanks for your reply rene...As you said, i removed Halt and donot clear option but nothing changed.

    RULE ENGINE TRACE for RULESET: A1 5/1/2015 10:21:53 AM

    FACT ACTIVITY 5/1/2015 10:21:53 AM
    Rule Engine Instance Identifier: 91daf735-13e8-4216-979e-5a418cfb4e83
    Ruleset Name: A1
    Operation: Assert
    Object Type: TypedXmlDocument:BOM.Class1
    Object Instance Identifier: 53068127

    FACT ACTIVITY 5/1/2015 10:21:53 AM
    Rule Engine Instance Identifier: 91daf735-13e8-4216-979e-5a418cfb4e83
    Ruleset Name: A1
    Operation: Assert - Fact Unrecognized
    Object Type: BrePrsent.Module1+PolicyExecutor
    Object Instance Identifier: 17363655

    FACT ACTIVITY 5/1/2015 10:21:53 AM
    Rule Engine Instance Identifier: 91daf735-13e8-4216-979e-5a418cfb4e83
    Ruleset Name: A1
    Operation: Assert
    Object Type: TypedXmlDocument:BOM.class2
    Object Instance Identifier: 14306053

    FACT ACTIVITY 5/1/2015 10:21:53 AM
    Rule Engine Instance Identifier: 91daf735-13e8-4216-979e-5a418cfb4e83
    Ruleset Name: A1
    Operation: Assert - Fact Unrecognized
    Object Type: BrePrsent.Module1+PolicyExecutor
    Object Instance Identifier: 59561931

    FACT ACTIVITY 5/1/2015 10:21:53 AM
    Rule Engine Instance Identifier: 91daf735-13e8-4216-979e-5a418cfb4e83
    Ruleset Name: A1
    Operation: Assert
    Object Type: TypedXmlDocument:BOM.Class1:/Class1
    Object Instance Identifier: 56307818

    CONDITION EVALUATION TEST (MATCH) 5/1/2015 10:21:53 AM
    Rule Engine Instance Identifier: 91daf735-13e8-4216-979e-5a418cfb4e83
    Ruleset Name: A1
    Test Expression: TypedXmlDocument:BOM.Class1:/Class1.name == Vinay
    Left Operand Value: Vinay
    Right Operand Value: Vinay
    Test Result: True

    CONDITION EVALUATION TEST (MATCH) 5/1/2015 10:21:53 AM
    Rule Engine Instance Identifier: 91daf735-13e8-4216-979e-5a418cfb4e83
    Ruleset Name: A1
    Test Expression: TypedXmlDocument:BOM.Class1:/Class1.Age != 31
    Left Operand Value: 12
    Right Operand Value: 31
    Test Result: True

    FACT ACTIVITY 5/1/2015 10:21:53 AM
    Rule Engine Instance Identifier: 91daf735-13e8-4216-979e-5a418cfb4e83
    Ruleset Name: A1
    Operation: Assert
    Object Type: TypedXmlDocument:BOM.class2:/class2
    Object Instance Identifier: 3014485

    CONDITION EVALUATION TEST (MATCH) 5/1/2015 10:21:53 AM
    Rule Engine Instance Identifier: 91daf735-13e8-4216-979e-5a418cfb4e83
    Ruleset Name: A1
    Test Expression: TypedXmlDocument:BOM.class2:/class2.Years == 32
    Left Operand Value: 12
    Right Operand Value: 32
    Test Result: False

    FACT ACTIVITY 5/1/2015 10:21:53 AM
    Rule Engine Instance Identifier: 91daf735-13e8-4216-979e-5a418cfb4e83
    Ruleset Name: A1
    Operation: Retract
    Object Type: TypedXmlDocument:BOM.Class1
    Object Instance Identifier: 53068127

    FACT ACTIVITY 5/1/2015 10:21:53 AM
    Rule Engine Instance Identifier: 91daf735-13e8-4216-979e-5a418cfb4e83
    Ruleset Name: A1
    Operation: Retract - Fact Unrecognized
    Object Type: BrePrsent.Module1+PolicyExecutor
    Object Instance Identifier: 17363655

    FACT ACTIVITY 5/1/2015 10:21:53 AM
    Rule Engine Instance Identifier: 91daf735-13e8-4216-979e-5a418cfb4e83
    Ruleset Name: A1
    Operation: Retract
    Object Type: TypedXmlDocument:BOM.class2
    Object Instance Identifier: 14306053

    FACT ACTIVITY 5/1/2015 10:21:53 AM
    Rule Engine Instance Identifier: 91daf735-13e8-4216-979e-5a418cfb4e83
    Ruleset Name: A1
    Operation: Retract - Fact Unrecognized
    Object Type: BrePrsent.Module1+PolicyExecutor
    Object Instance Identifier: 59561931

    FACT ACTIVITY 5/1/2015 10:21:53 AM
    Rule Engine Instance Identifier: 91daf735-13e8-4216-979e-5a418cfb4e83
    Ruleset Name: A1
    Operation: Retract
    Object Type: TypedXmlDocument:BOM.Class1:/Class1
    Object Instance Identifier: 56307818

    FACT ACTIVITY 5/1/2015 10:21:53 AM
    Rule Engine Instance Identifier: 91daf735-13e8-4216-979e-5a418cfb4e83
    Ruleset Name: A1
    Operation: Retract
    Object Type: TypedXmlDocument:BOM.class2:/class2
    Object Instance Identifier: 3014485

    Friday, May 1, 2015 2:25 PM
  • Hi,

    What are you trying to establish, i.e. what are the requirements?

    If you remove the update from youre second rule and change the update from the first rule from updating BOM to updating BOM.Class2, at least the rule are fired, but as I do not know what your reqs are, it might not be the output you need.

    Regards,

    René

    Friday, May 1, 2015 3:17 PM
  • My requirement is simple..

    Based on the condition in first rule, i have to updated necessary value. I have to use the updated value in the second rule to assign new values..

    Rule1:

    if class1.name = name

    then class1.age = 32

    class2.years = 32

    Rule2

    if class2. years =32

    then class2.months = 322

    Rule 1 supplies values to rule 2

    Friday, May 1, 2015 3:47 PM
  • Well the rules work now.

    1. StaticSupport to 1 in regedit, ruleengine.exe.config and BTSNTSvc.exe

    2. Document type was given wrong when rule was neither validated nor executed.

    Once the rules are evaluated and rules not fired,

    3. The Type for the root was system.string(need to be microsoft.ruleengine.typedxmldocument)

    4. Issue was that i was updating the Class instead of class1 and class2. updating the right root node.

    Thanks for the help Rene.


    • Edited by bvinay Tuesday, May 5, 2015 8:56 PM 3.
    • Marked as answer by Angie Xu Wednesday, May 13, 2015 8:22 AM
    Tuesday, May 5, 2015 8:53 PM