Microsoft Developer Network > Forums Home > BizTalk Server Forums > BizTalk ESB Toolkit > BRI Rule Problem with Content Based Routing
Ask a questionAsk a question
 

AnswerBRI Rule Problem with Content Based Routing

  • Thursday, November 05, 2009 4:21 PMMikeGBUK Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Hi,

    I am using the ESB generic WCF receive port and I am using a "generic" business rule to assign the correct itinerary. I am having a problem writing a business rule that does this:

    IF Context Message Type = "some-doc-spec-1"
      AND
        (doc-content = 'X' OR doc-content = 'Y')
    OR Context Message Type = "some-doc-spec-2"
    OR Context Message Type = "some-doc-spec-3"
    THEN
      Set Itinerary Name = zzzz 

    Using the above rule, messages of context type "some-doc-spec-1" get selected if they have the correct content, but never for the "OR" conditions. The BRE rule is actually written as:

    OR
    |_ AND
    |    |_   Context Message Type = "some-doc-spec-1" 
    |    |_   OR
    |           |_ doc-content = 'X'
    |           |_ doc-content = 'Y'
    |_  Context Message Type = "some-doc-spec-2"
    |_  Context Message Type = "some-doc-spec-3"

    If I split this rule into 2 rules by putting the outer OR's into another rule:

    IF Context Message Type = "some-doc-spec-1"
      AND
        (doc-content = 'X' OR doc-content = 'Y')
    THEN
      Set Itinerary Name = zzzz 

    plus:

    IF  Context Message Type = "some-doc-spec-2"
    OR Context Message Type = "some-doc-spec-3"
    THEN
      Set Itinerary Name = zzzz 

    then itineraries are set for all document types. But this is not ideal - I would rather have one rule per itinerary so I can see all the logic in one place.

    Thus it seems you can't have a rule that mixes CONTENT based routing with CONTEXT based routing for different

    Does anyone know how to invoke "Test Policy" to test a BRI rule? I believe you need fact creators for the ESB facts, but I don't know where they are.

Answers

  • Wednesday, November 11, 2009 6:40 AMAndrew_ZhuMSFT, ModeratorUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer
    Hi,Mike

    In this rule:
    OR
    |_ AND
    |    |_   Context Message Type = "some-doc-spec-1" 
    |    |_   OR
    |           |_ doc-content = 'X'
    |           |_ doc-content = 'Y'
    |_  Context Message Type = "some-doc-spec-2"
    |_  Context Message Type = "some-doc-spec-3"

    If sub condition AND
                               |_   Context Message Type = "some-doc-spec-1" 
                               |_   OR
                                        |_ doc-content = 'X'
                                        |_ doc-content = 'Y'
    Is true, then, rule judgment will finish, action will take place. in other word, the following two conditions will not function if the first sub condition equals True.

    Try change the rule to this:
    AND
    |_ AND
    |    |_   Context Message Type = "some-doc-spec-1" 
    |    |_   OR
    |           |_ doc-content = 'X'
    |           |_ doc-content = 'Y'
    |_OR
         |_Context Message Type = "some-doc-spec-2"
         |_Context Message Type = "some-doc-spec-3"

    Hope it meets your requirement.
    Regards
    This posting is provided "AS IS" with no warranties, and confers no rights. Microsoft Online Community Support

All Replies

  • Wednesday, November 11, 2009 6:40 AMAndrew_ZhuMSFT, ModeratorUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer
    Hi,Mike

    In this rule:
    OR
    |_ AND
    |    |_   Context Message Type = "some-doc-spec-1" 
    |    |_   OR
    |           |_ doc-content = 'X'
    |           |_ doc-content = 'Y'
    |_  Context Message Type = "some-doc-spec-2"
    |_  Context Message Type = "some-doc-spec-3"

    If sub condition AND
                               |_   Context Message Type = "some-doc-spec-1" 
                               |_   OR
                                        |_ doc-content = 'X'
                                        |_ doc-content = 'Y'
    Is true, then, rule judgment will finish, action will take place. in other word, the following two conditions will not function if the first sub condition equals True.

    Try change the rule to this:
    AND
    |_ AND
    |    |_   Context Message Type = "some-doc-spec-1" 
    |    |_   OR
    |           |_ doc-content = 'X'
    |           |_ doc-content = 'Y'
    |_OR
         |_Context Message Type = "some-doc-spec-2"
         |_Context Message Type = "some-doc-spec-3"

    Hope it meets your requirement.
    Regards
    This posting is provided "AS IS" with no warranties, and confers no rights. Microsoft Online Community Support