Home Page › Forums › BizTalk 2004 – BizTalk 2010 › Rules execution Problem
- This topic has 3 replies, 1 voice, and was last updated 9 years, 5 months ago by
community-content.
-
AuthorPosts
-
-
September 27, 2006 at 2:07 PM #15875
Hi,
I am trying to execute a buisness rule based on a small condition
Policy
Rule1
if Age is between 50 and 90 then
Action Agestatus="SeniorCitizens"
Update Schema
Rule2
if Agestatus=SeniorCitizens then
Action policy="Pension"
I am trying do this using the below given schema
When I am trying to test in rules engine I found that Rule 2 is firing first even though I set the proirity to execute Rule 1. I didn't undestood. Could you please let me know where I am doing wrong.
(My intentions is to update Agestatus in the same instance and trying to use the same value for the next rule. Is that wont work please let me know)
<?xml version="1.0" encoding="utf-16"?>
<xs:schema xmlns:b="http://schemas.microsoft.com/BizTalk/2003" xmlns="http://empBusinessRules.Schema1" targetNamespace="http://empBusinessRules.Schema1" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="Employees">
<xs:complexType>
<xs:sequence>
<xs:element name="Employee">
<xs:complexType>
<xs:sequence>
<xs:element name="Name" type="xs:string" />
<xs:element name="Age" type="xs:integer" />
<xs:element name="AgeStatus" type="xs:string" />
<xs:element name="Policy" type="xs:string" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>Policy here is
<?xml version="1.0" encoding="utf-8"?>
<brl xmlns="http://schemas.microsoft.com/businessruleslanguage/2002">
<ruleset name="Age">
<version major="1" minor="0" description="" modifiedby="ACES\srao" date="2006-09-27T16:00:04.2548726-05:00" />
<configuration />
<bindings>
<xmldocument ref="xml_31" doctype="Schema1" instances="16" selectivity="1" instance="0">
<selector>/*[local-name()='Employees' and namespace-uri()='http://empBusinessRules.Schema1'%5D/*%5Blocal-name()='Employee' and namespace-uri()='']</selector>
<schema>C:\Documents and Settings\srao\My Documents\Visual Studio 2005\Projects\empBusinessRules\empBusinessRules\Schema1.xsd</schema>
</xmldocument>
</bindings>
<rule name="StatusPolicy" priority="200" active="true">
<if>
<compare operator="equal">
<vocabularylink uri="3f0e9bcc-6212-4e6a-853c-e517f157a626" element="05703dd9-1111-40b8-890d-ad7bfc45a925" />
<lhs>
<function>
<vocabularylink uri="58e1d4d2-a944-4cf5-9fb0-38957285c148" element="81b9425d-50c2-447f-8cdb-530798fd3a02" />
<xmldocumentmember xmldocumentref="xml_31" type="string" sideeffects="false">
<field>*[local-name()='AgeStatus' and namespace-uri()='']</field>
<fieldalias>AgeStatus</fieldalias>
</xmldocumentmember>
</function>
</lhs>
<rhs>
<constant>
<string>SeniorCitizens</string>
</constant>
</rhs>
</compare>
</if>
<then>
<function>
<vocabularylink uri="58e1d4d2-a944-4cf5-9fb0-38957285c148" element="5ba6f475-3fdf-452b-b8bb-ee97722d6c97" />
<xmldocumentmember xmldocumentref="xml_31" type="string" sideeffects="true">
<field>*[local-name()='Policy' and namespace-uri()='']</field>
<fieldalias>Policy</fieldalias>
<argument>
<constant>
<string>Pension</string>
</constant>
</argument>
</xmldocumentmember>
</function>
</then>
</rule>
<rule name="AgeRange" priority="300" active="true">
<if>
<range>
<vocabularylink uri="3f0e9bcc-6212-4e6a-853c-e517f157a626" element="aff538e1-89fd-4773-b991-0363b7f0d5c2" />
<testvalue>
<function>
<vocabularylink uri="58e1d4d2-a944-4cf5-9fb0-38957285c148" element="ed6c61df-7566-440d-a157-58e094abf7f5" />
<xmldocumentmember xmldocumentref="xml_31" type="decimal" sideeffects="false">
<field>*[local-name()='Age' and namespace-uri()='']</field>
<fieldalias>Age</fieldalias>
</xmldocumentmember>
</function>
</testvalue>
<rangehigh>
<constant>
<decimal>90</decimal>
</constant>
</rangehigh>
<rangelow>
<constant>
<decimal>50</decimal>
</constant>
</rangelow>
</range>
</if>
<then>
<function>
<vocabularylink uri="58e1d4d2-a944-4cf5-9fb0-38957285c148" element="8e063d10-0b3b-4c63-80a0-d88810db2af8" />
<xmldocumentmember xmldocumentref="xml_31" type="string" sideeffects="true">
<field>*[local-name()='AgeStatus' and namespace-uri()='']</field>
<fieldalias>AgeStatus</fieldalias>
<argument>
<constant>
<string>SeniorCitizens</string>
</constant>
</argument>
</xmldocumentmember>
</function>
</then>
</rule>
</ruleset>
</brl>here the vocabulary is
<?xml version="1.0" encoding="utf-8"?>
<brl xmlns="http://schemas.microsoft.com/businessruleslanguage/2002">
<vocabulary id="58e1d4d2-a944-4cf5-9fb0-38957285c148" name="Age" uri="" description="">
<version major="1" minor="0" description="" modifiedby="ACES\srao" date="2006-09-27T15:51:06.4198634-05:00" />
<vocabularydefinition id="8e063d10-0b3b-4c63-80a0-d88810db2af8" name="AgeStatus" description="">
<bindingdefinition>
<documentelementbindingdefinition field="*[local-name()='AgeStatus' and namespace-uri()='']" fieldalias="AgeStatus" type="string">
<documentinfo schema="C:\Documents and Settings\srao\My Documents\Visual Studio 2005\Projects\empBusinessRules\empBusinessRules\Schema1.xsd" documenttype="Schema1" selector="/*[local-name()='Employees' and namespace-uri()='http://empBusinessRules.Schema1'%5D/*%5Blocal-name()='Employee' and namespace-uri()='']" selectoralias="/*[local-name()='Employees' and namespace-uri()='http://empBusinessRules.Schema1'%5D/*%5Blocal-name()='Employee' and namespace-uri()='']" instance="0" />
<argument position="0">
<valuedefinitionliteral type="string">
<string />
</valuedefinitionliteral>
</argument>
</documentelementbindingdefinition>
</bindingdefinition>
<formatstring language="en-US" string="AgeStatus {0}" delimiter="{[0-9]+}">
<argument position="0">
<valuedefinitionliteral type="string">
<string />
</valuedefinitionliteral>
</argument>
</formatstring>
</vocabularydefinition>
<vocabularydefinition id="81b9425d-50c2-447f-8cdb-530798fd3a02" name="AgeStatusRead" description="">
<bindingdefinition>
<documentelementbindingdefinition field="*[local-name()='AgeStatus' and namespace-uri()='']" fieldalias="AgeStatus" type="string">
<documentinfo schema="C:\Documents and Settings\srao\My Documents\Visual Studio 2005\Projects\empBusinessRules\empBusinessRules\Schema1.xsd" documenttype="Schema1" selector="/*[local-name()='Employees' and namespace-uri()='http://empBusinessRules.Schema1'%5D/*%5Blocal-name()='Employee' and namespace-uri()='']" selectoralias="/*[local-name()='Employees' and namespace-uri()='http://empBusinessRules.Schema1'%5D/*%5Blocal-name()='Employee' and namespace-uri()='']" instance="0" />
</documentelementbindingdefinition>
</bindingdefinition>
<formatstring language="en-US" string="AgeStatusRead" />
</vocabularydefinition>
<vocabularydefinition id="ed6c61df-7566-440d-a157-58e094abf7f5" name="Age" description="">
<bindingdefinition>
<documentelementbindingdefinition field="*[local-name()='Age' and namespace-uri()='']" fieldalias="Age" type="decimal">
<documentinfo schema="C:\Documents and Settings\srao\My Documents\Visual Studio 2005\Projects\empBusinessRules\empBusinessRules\Schema1.xsd" documenttype="Schema1" selector="/*[local-name()='Employees' and namespace-uri()='http://empBusinessRules.Schema1'%5D/*%5Blocal-name()='Employee' and namespace-uri()='']" selectoralias="/*[local-name()='Employees' and namespace-uri()='http://empBusinessRules.Schema1'%5D/*%5Blocal-name()='Employee' and namespace-uri()='']" instance="0" />
</documentelementbindingdefinition>
</bindingdefinition>
<formatstring language="en-US" string="Age" />
</vocabularydefinition>
<vocabularydefinition id="5ba6f475-3fdf-452b-b8bb-ee97722d6c97" name="Policy" description="">
<bindingdefinition>
<documentelementbindingdefinition field="*[local-name()='Policy' and namespace-uri()='']" fieldalias="Policy" type="string">
<documentinfo schema="C:\Documents and Settings\srao\My Documents\Visual Studio 2005\Projects\empBusinessRules\empBusinessRules\Schema1.xsd" documenttype="Schema1" selector="/*[local-name()='Employees' and namespace-uri()='http://empBusinessRules.Schema1'%5D/*%5Blocal-name()='Employee' and namespace-uri()='']" selectoralias="/*[local-name()='Employees' and namespace-uri()='http://empBusinessRules.Schema1'%5D/*%5Blocal-name()='Employee' and namespace-uri()='']" instance="0" />
<argument position="0">
<valuedefinitionliteral type="string">
<string />
</valuedefinitionliteral>
</argument>
</documentelementbindingdefinition>
</bindingdefinition>
<formatstring language="en-US" string="Policy {0}" delimiter="{[0-9]+}">
<argument position="0">
<valuedefinitionliteral type="string">
<string />
</valuedefinitionliteral>
</argument>
</formatstring>
</vocabularydefinition>
</vocabulary>
</brl> -
September 28, 2006 at 7:47 AM #15881See if the recent post by one of our BRE tech writers helps … http://blogs.msdn.com/biztalkbre/archive/2006/09/15/756626.aspx. I'm wondering if you're "updating" the wrong fact. Can you try just updating "agestatus"?
-
September 28, 2006 at 8:45 AM #15883
Hi,
Thanks for your reply. I updated the Agestatus fact. Even though I am still not able to fire Rule1.
Please find the output while testing it in rules engine. Could you please let me know what's the problem is
ULE ENGINE TRACE for RULESET: Age 9/28/2006 10:41:45 AM
FACT ACTIVITY 9/28/2006 10:41:45 AM
Rule Engine Instance Identifier: 2ac8c9b1-b1a1-443c-9481-0d864d2c1ace
Ruleset Name: Age
Operation: Assert
Object Type: TypedXmlDocument:Schema1
Object Instance Identifier: 3959276FACT ACTIVITY 9/28/2006 10:41:45 AM
Rule Engine Instance Identifier: 2ac8c9b1-b1a1-443c-9481-0d864d2c1ace
Ruleset Name: Age
Operation: Assert
Object Type: TypedXmlDocument:Schema1:/*[local-name()='Employees' and namespace-uri()='http://empBusinessRules.Schema1'%5D/*%5Blocal-name()='Employee' and namespace-uri()='']
Object Instance Identifier: 35633491CONDITION EVALUATION TEST (MATCH) 9/28/2006 10:41:45 AM
Rule Engine Instance Identifier: 2ac8c9b1-b1a1-443c-9481-0d864d2c1ace
Ruleset Name: Age
Test Expression: TypedXmlDocument:Schema1:/*[local-name()='Employees' and namespace-uri()='http://empBusinessRules.Schema1'%5D/*%5Blocal-name()='Employee' and namespace-uri()=''].AgeStatus == SeniorCitizens
Left Operand Value:
Right Operand Value: SeniorCitizens
Test Result: FalseCONDITION EVALUATION TEST (MATCH) 9/28/2006 10:41:45 AM
Rule Engine Instance Identifier: 2ac8c9b1-b1a1-443c-9481-0d864d2c1ace
Ruleset Name: Age
Test Expression: True == Range(90, 50, TypedXmlDocument:Schema1:/*[local-name()='Employees' and namespace-uri()='http://empBusinessRules.Schema1'%5D/*%5Blocal-name()='Employee' and namespace-uri()=''].Age)
Left Operand Value: True
Right Operand Value: True
Test Result: TrueAGENDA UPDATE 9/28/2006 10:41:45 AM
Rule Engine Instance Identifier: 2ac8c9b1-b1a1-443c-9481-0d864d2c1ace
Ruleset Name: Age
Operation: Add
Rule Name: AgeRange
Conflict Resolution Criteria: 500RULE FIRED 9/28/2006 10:41:45 AM
Rule Engine Instance Identifier: 2ac8c9b1-b1a1-443c-9481-0d864d2c1ace
Ruleset Name: Age
Rule Name: AgeRange
Conflict Resolution Criteria: 500FACT ACTIVITY 9/28/2006 10:41:45 AM
Rule Engine Instance Identifier: 2ac8c9b1-b1a1-443c-9481-0d864d2c1ace
Ruleset Name: Age
Operation: Update – Fact Unrecognized
Object Type: System.String
Object Instance Identifier: -2076391006FACT ACTIVITY 9/28/2006 10:41:45 AM
Rule Engine Instance Identifier: 2ac8c9b1-b1a1-443c-9481-0d864d2c1ace
Ruleset Name: Age
Operation: Retract
Object Type: TypedXmlDocument:Schema1
Object Instance Identifier: 3959276FACT ACTIVITY 9/28/2006 10:41:45 AM
Rule Engine Instance Identifier: 2ac8c9b1-b1a1-443c-9481-0d864d2c1ace
Ruleset Name: Age
Operation: Retract
Object Type: TypedXmlDocument:Schema1:/*[local-name()='Employees' and namespace-uri()='http://empBusinessRules.Schema1'%5D/*%5Blocal-name()='Employee' and namespace-uri()='']
Object Instance Identifier: 35633491——————————————————————————–
-
-
-
AuthorPosts
- The forum ‘BizTalk 2004 – BizTalk 2010’ is closed to new topics and replies.