BizTalk Server General - Rules Engine Rules Fired Tracking Info, Capture only Rules fired Info

This is Interesting: Free IT Magazines  
Home > Archive > BizTalk Server General > March 2005 > Rules Engine Rules Fired Tracking Info, Capture only Rules fired Info





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author Rules Engine Rules Fired Tracking Info, Capture only Rules fired Info
sandeep_kesiraju@countrywide.com

2005-02-22, 5:50 pm

Trying to capture only the rules fired info using the Tracking
Interceptor provided.

The following is a piece of code I use, any help would be great.


DebugTrackingInterceptor dti = new
DebugTrackingInterceptor(traceFileName);

string PolicyName = "TEST POLICY";
Policy tstPolicy = new Policy(PolicyName);
ArrayList shortTermFacts = new ArrayList();
shortTermFacts =GetFacts(PolicyName);
shortTermFacts.Add(doc1);
tstPolicy.Execute(shortTermFacts.ToArray(), dti );
tstPolicy = null;
StreamWriter sw = new StreamWriter(processedDoc);
dti.CloseTraceFile();

The above captures all the rules fired info i mean to say AGENDA
UPDATES, RULES FIRED, CONDITIONS EVALUATED, and FACT ACTIVITY. Only
need the rules fired info.

Tried creating a custom "IRuleSetTrackingInterceptor" but of no Help.
Heard we could set the tracking configuration using the
Tracking Configuration, but is Read only.

Any help would be great. Thanks in advance

WenJun Zhang[msft]

2005-02-23, 7:46 am

Hi,

Yes, looks like the members of TrackingConfiguration class are
read-only. Currently I also have no idea about how to use the
SetTrackingConfig method to customize the tracking format.

I'd do some researching on this issue and plan on discussing it with
some guys in out internal. As soon as I get any info, I'll update
here to let you know.

Thanks.

Best regards,

WenJun Zhang
Microsoft Online Partner Support

This posting is provided "AS IS" with no warranties, and confers no
rights.

sandeep_kesiraju@countrywide.com

2005-02-23, 5:58 pm

Tried to do that as well, used this

DebugTrackingInterceptor dti = new
DebugTrackingInterceptor(traceFileName);

RuleSetTrackingConfiguration tc = new RuleSetTrackingConfiguration(new
Guid(),2 );
tc.TrackingFlags = 2;
// tracking flag 2 will track only rules fired
dti.SetTrackingConfig(tc);

string PolicyName = "TEST POLICY";
Policy tstPolicy = new Policy(PolicyName);
ArrayList shortTermFacts = new ArrayList();
shortTermFacts =GetFacts(PolicyName);
shortTermFacts.Add(doc1);
tstPolicy.Execute(shortTermFacts.ToArray(), dti );
tstPolicy = null;
StreamWriter sw = new StreamWriter(processedDoc);
dti.CloseTraceFile();



for the Flag 2 for the TrackingFlags in RuleSetTrackingConfiguration
the following are the properties
{Microsoft.RuleEngine.RuleSetTrackingConfiguration}
Microsoft.RuleEngine.TrackingConfiguration:
{Microsoft.RuleEngine.RuleSetTrackingConfiguration}
m_ruleSetGuid: {System.Guid}
m_trackingFlags: 2
RuleSetGuid: {System.Guid}
TrackAgendaUpdates: false
TrackConditionEvaluation: false
TrackFactActivity: false
TrackingFlags: 2
TrackRuleFirings: true

so by this it should only be tracking the rules fired, but tracks
everything.
could you please check this.

WenJun Zhang[msft]

2005-02-24, 2:50 am

I've got conclusion of this issue. The tracking configuration on the
debug tracker cannot be changed, but implementing the interface to
track what we want is straightforward. Here is a sample for your
reference:


using System;

using System.Diagnostics;

using Microsoft.RuleEngine;



namespace TraceListener

{

public class TraceListener : IRuleSetTrackingInterceptor

{

public TraceListener()

{

}



public void
SetTrackingConfig(TrackingConfiguration trackingConfig)

{

}



public void TrackRuleSetEngineAssociation(

RuleSetInfo ruleSetInfo,

Guid ruleEngineGuid)

{

}



public void
TrackFactActivity(FactActivityType activityType, string classType,
int classInstanceId)

{


Debug.WriteLine(activityType.ToString() + ": " + classType);

}



public void TrackConditionEvaluation(

string testExpression,

string leftClassType,

int leftClassInstanceId,

object leftValue,

string rightClassType,

int rightClassInstanceId,

object rightValue,

bool result)

{

Debug.WriteLine(testExpression +
": " + result.ToString());

}



public void TrackAgendaUpdate(bool
isAddition, string ruleName, object conflictResolutionCriteria)

{

if ( isAddition )

{

Debug.WriteLine("Add:
" + ruleName);

}

else

{


Debug.WriteLine("Remove: " + ruleName);

}

}



public void TrackRuleFiring(string ruleName,
object conflictResolutionCriteria)

{

Debug.WriteLine("Fire: " +
ruleName);



}

}

}


Thanks.

Best regards,

WenJun Zhang
Microsoft Online Partner Support

This posting is provided "AS IS" with no warranties, and confers no
rights.

sandeep_kesiraju@countrywide.com

2005-02-24, 5:51 pm

how does this help? could you please help me with some implementation
code, looks like i am missing something big

Thanks so much for your help.

WenJun Zhang[msft]

2005-02-25, 2:50 am

You are welcome. :-)

What I meant is we have to implement our own tracker class from the
IRuleSetTrackingInterceptor interface to perform a customized
tracking and logging.

As you can see the code I provided is just a demo. Since you are
looking for the Rule Fired events, add some System.IO.FileStream code
in the TrackRuleFiring method to write the Rule Fired info in your
log file. Remove code in TrackAgendaUpdate..etc to make those
functions do nothing since you are not interested in them. Then when
calling Policy.Execute , populate your own tracker class instance as
the tracking interceptor instead of the built-in
DebugTrackingInterceptor.

Feel free to let me know if there is still anything unclear.
Thanks.

Best regards,

WenJun Zhang
Microsoft Online Partner Support

This posting is provided "AS IS" with no warranties, and confers no
rights.

sandeep_kesiraju@countrywide.com

2005-02-26, 2:50 am

Thanks WenJun Will Try to implement this on monday and let you know how
it goes, bare with me here, trying this out for a long time.
Thanks
Sandeep Kesiraju

sandeep_kesiraju@countrywide.com

2005-02-26, 2:50 am

Thanks WenJun Will Try to implement this on monday and let you know how
it goes, bare with me here, trying this out for a long time.
Thanks
Sandeep Kesiraju

WenJun Zhang[msft]

2005-02-28, 2:47 am

It's ok. Glad to be of help. :-)

Best regards,

WenJun Zhang
Microsoft Online Partner Support

This posting is provided "AS IS" with no warranties, and confers no
rights.

sandeep_kesiraju@countrywide.com

2005-03-05, 5:52 pm

Hi,

Tried to implement the TraceListener was not successful, built a
inhouse logging mechanism in the rule actions to log when a rule fires,
that helped out. Thanks so much for help. Will try again to implement
this again.

The logging mechanism works like this, when ever a rule fires i put a
rule action as a logging mechanism to write the rule fired info to the
xml, so this helped out.

Thanks
Sandeep Kesiraju

WenJun Zhang[msft]

2005-03-07, 2:47 am

Glad to hear the issue has been worked around by you finally. Not
sure why the custom tracer approach didn't work at your side, but
anyway I think you are fine on this issue now. :-) Please don't
hesitate to post in the newsgroup again if you have any other issues
in future.

Thanks.

Best regards,

WenJun Zhang
Microsoft Online Partner Support

This posting is provided "AS IS" with no warranties, and confers no
rights.

Shane

2005-03-23, 6:01 pm

v-wzhang@online.microsoft.com ("WenJun Zhang[msft]") wrote in message news:<6LBhzfkGFHA.3164@TK2MSFTNGXA02.phx.gbl>...
> I've got conclusion of this issue. The tracking configuration on the
> debug tracker cannot be changed, but implementing the interface to
> track what we want is straightforward. Here is a sample for your
> reference:
>


I tried the above sample, but because I'm not able to modify the
trackingConfiguration only TrackRuleSetEngineAssociation and
TrackRuleFiring are called. Is there any way to have the
TrackConditionEvaluation method called?

Thanks in advance

shane
Shane

2005-03-23, 6:01 pm

v-wzhang@online.microsoft.com ("WenJun Zhang[msft]") wrote in message news:<#AVh7LxGFHA.964@TK2MSFTNGXA02.phx.gbl>...
> You are welcome. :-)
>
> What I meant is we have to implement our own tracker class from the
> IRuleSetTrackingInterceptor interface to perform a customized
> tracking and logging.
>
> As you can see the code I provided is just a demo. Since you are
> looking for the Rule Fired events, add some System.IO.FileStream code
> in the TrackRuleFiring method to write the Rule Fired info in your
> log file. Remove code in TrackAgendaUpdate..etc to make those
> functions do nothing since you are not interested in them. Then when
> calling Policy.Execute , populate your own tracker class instance as
> the tracking interceptor instead of the built-in
> DebugTrackingInterceptor.
>
> Feel free to let me know if there is still anything unclear.
> Thanks.
>
> Best regards,
>
> WenJun Zhang
> Microsoft Online Partner Support
>
> This posting is provided "AS IS" with no warranties, and confers no
> rights.


I'm implemented this interface, but it does not appear that
TrackConditionEvaluation is being called. Since I can not update the
trackingconfiguration should i assume that I will not be able to
capture the condition details? Is there are a way to enable this
outside of TrackingConfiguration?

Thanks

shane
sandeep_kesiraju@countrywide.com

2005-03-30, 5:51 pm

Its better that you write an custom interface or build in logging
capability into your rules. I tried to implement the same but was nto
succesful.

I built in the logging into the business object which goes into the
rules and comes out, so the business object is populated with the rules
fired information when ever a rule is fired.

Sandeep Kesiraju

Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com