WF BAM Interceptor - Tracking multiple events on an activity

Hi,

I am new to WF BAM interceptor.BizTalk 2006 R2 documentation mentions that we can track different events of a single activity using multiple OnEvent elements in the IC file.

However, I am facing problem when trying to track multiple events on a single WF activity using BamTrackingService.

I am using GetActivityEvent for this.

I have created a custom activity 'SampleActivity' and I am trying to track its 'executing' and 'closed' events.

In the tracking profile, it shows that 2 activity track points are created. However, only the 'closed' event is getting tracked.

With multiple combinations it was observed that the if an event later that current event in the life cycle of the activity exists in the tracking profile, then the current event does not get tracked.

E.g. If Closed event is tracked then no other event gets tracked, If any event after 'Executing' (like Faulting, Canceling, Compensating, Closed) is tracked then executing does not get tracked.

The IC file is as follows:

Code Snippet

<?xmlversion="1.0"encoding="utf-8" ?>

<ic:InterceptorConfiguration

xmlns:ic="http://schemas.microsoft.com/BizTalkServer/2004/10/BAM/InterceptorConfiguration"

xmlns:wf="http://schemas.microsoft.com/BizTalkServer/2004/10/BAM/WorkflowInterceptorConfiguration">

<ic:EventSourceName="Workflow1"Technology="WF"

Manifest="SampleWorkflow.Workflow1, SampleWorkflow, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"/>

<ic:BamActivityName="SampleActivity">

<ic:OnEventName="ClosedEvent"Source="Workflow1"IsEnd="true"IsBegin="true">

<ic:Filter>

<ic:Expression>

<wf:OperationName="GetActivityName"/>

<ic:OperationName="Constant">

<ic:Argument>sampleActivity1</ic:Argument>

</ic:Operation>

<ic:OperationName="Equals"/>

<wf:OperationName="GetActivityEvent"/>

<ic:OperationName="Constant">

<ic:Argument>Closed</ic:Argument>

</ic:Operation>

<ic:OperationName="Equals"/>

<ic:OperationName="And"/>

</ic:Expression>

</ic:Filter>

<ic:CorrelationID>

<ic:Expression>

<wf:OperationName="GetContextProperty">

<wf:Argument>InstanceId</wf:Argument>

</wf:Operation>

</ic:Expression>

</ic:CorrelationID>

<ic:UpdateDataItemName="DataItemActName"Type="NVARCHAR">

<ic:Expression>

<wf:OperationName="GetActivityProperty">

<wf:Argument>Name</wf:Argument>

</wf:Operation>

</ic:Expression>

</ic:Update>

<ic:UpdateDataItemName="DataItemEvtName"Type="NVARCHAR">

<ic:Expression>

<wf:OperationName="GetActivityEvent"/>

</ic:Expression>

</ic:Update>

<ic:UpdateDataItemName="DataItemActStatus"Type="NVARCHAR">

<ic:Expression>

<wf:OperationName="GetActivityProperty">

<wf:Argument>ExecutionResult</wf:Argument>

</wf:Operation>

</ic:Expression>

</ic:Update>

<ic:UpdateDataItemName="DataItemWhen"Type="DATETIME">

<ic:Expression>

<wf:OperationName="GetActivityProperty">

<wf:Argument>When</wf:Argument>

</wf:Operation>

</ic:Expression>

</ic:Update>

<ic:UpdateDataItemName="DataItemValue"Type="INT">

<ic:Expression>

<wf:OperationName="GetActivityProperty">

<wf:Argument>Value</wf:Argument>

</wf:Operation>

</ic:Expression>

</ic:Update>

</ic:OnEvent>

<ic:OnEventName="ExecutingEvent"Source="Workflow1"IsBegin="true"IsEnd="true">

<ic:Filter>

<ic:Expression>

<wf:OperationName="GetActivityName"/>

<ic:OperationName="Constant">

<ic:Argument>sampleActivity1</ic:Argument>

</ic:Operation>

<ic:OperationName="Equals"/>

<wf:OperationName="GetActivityEvent"/>

<ic:OperationName="Constant">

<ic:Argument>Executing</ic:Argument>

</ic:Operation>

<ic:OperationName="Equals"/>

<ic:OperationName="And"/>

</ic:Expression>

</ic:Filter>

<ic:CorrelationID>

<ic:Expression>

<wf:OperationName="GetContextProperty">

<wf:Argument>InstanceId</wf:Argument>

</wf:Operation>

</ic:Expression>

</ic:CorrelationID>

<ic:UpdateDataItemName="DataItemActName"Type="NVARCHAR">

<ic:Expression>

<wf:OperationName="GetActivityProperty">

<wf:Argument>Name</wf:Argument>

</wf:Operation>

</ic:Expression>

</ic:Update>

<ic:UpdateDataItemName="DataItemEvtName"Type="NVARCHAR">

<ic:Expression>

<wf:OperationName="GetActivityEvent"/>

</ic:Expression>

</ic:Update>

<ic:UpdateDataItemName="DataItemActStatus"Type="NVARCHAR">

<ic:Expression>

<wf:OperationName="GetActivityProperty">

<wf:Argument>ExecutionResult</wf:Argument>

</wf:Operation>

</ic:Expression>

</ic:Update>

</ic:OnEvent>

</ic:BamActivity>

</ic:InterceptorConfiguration>

Please let me know if this is the expected behavior or is it a bug or am I missing something?

Thanks and Regards,

Kapil

[29263 byte] By [KapilJoshi] at [2008-2-25]
# 1

Hi Kapil,

Are you seeing any errors in the Event Log or are you seeing your workflow instance getting terminated instead of gracefully finishing?

From your IC file above, it looks like both OnEvents for 'Closed' and 'Executing' activity events are going to Begin and End a BAM activity instance using the same activity ID - since you have specified InstanceId (which is the workflow instance ID) under CorrelationID for both OnEvents.

BAM activity instances need to have unique IDs so semantically this IC seems incorrect. If you want to track the different workflow values at different times of the activity lifecycle, you can do one of the following:

1) Add more checkpoints to your BAM activity. Each OnEvent above will update different checkpoints. You can keep using InstanceId as the BAM activity ID.

2) Don't use InstanceId in both OnEvents. Provide a way to generate a unique ID. For example, in the IC we have a concatenation operation, so you could do InstanceId + some constant value.

HTH,

-Andy

AndyShen(CSD) at 2007-10-2 > top of Msdn Tech,BizTalk Server,BizTalk Interceptors...