|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Workflow - CallExternalMethod -Correlation value is already intialInvalidOperationException - Correlation value is already initialized I have a workflow that needs to call out to an external event until the event responds with a result of true. Unfortunately, the second time I call the external event, I get the error that the Correlation value is already initialized. I've implemented this with a while loop that has the condition that the result is true or an elapsed time of one hour has occured. The first activity in the loop is to call the external activity. The second is to delay for five minutes. Pretty simple. I've included the full error message the XOML and the code behind below. Has anyone run into this situation? Is there a way around it? Thanks in advance for any help. Jeff ExtractPackaging.BusinessLogic.ExtractIssuePackagingActivity Error: 1 : HandleFaultCode_ExecuteCodeystem.InvalidOperationException: Correlation value on declaration "ActivityContextGuidCorrelationToken" is already initialized. at System.Workflow.Runtime.CorrelationToken.Initialize(Activity activity, ICollection`1 propertyValues) at System.Workflow.Activities.CorrelationService.InvalidateCorrelationToken(Activity activity, Type interfaceType, String methodName, Object[] messageArgs) at System.Workflow.Activities.CallExternalMethodActivity.Execute(ActivityExecutionContext executionContext) at System.Workflow.ComponentModel.ActivityExecutor`1.Execute(T activity, ActivityExecutionContext executionContext) at System.Workflow.ComponentModel.ActivityExecutor`1.Execute(Activity activity, ActivityExecutionContext executionContext) at System.Workflow.ComponentModel.ActivityExecutorOperation.Run(IWorkflowCoreRuntime workflowCoreRuntime) at System.Workflow.Runtime.Scheduler.Run() <SequenceActivity x:Class="ExtractPackaging.BusinessLogic.ExtractIssuePackagingActivity" x:Name="ExtractIssuePackagingActivity" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/workflow"> <CodeActivity x:Name="AcceptRequest" ExecuteCode="AcceptRequest_ExecuteCode" /> <ParallelActivity x:Name="ReadyForPackagingCheckAndWait"> <SequenceActivity x:Name="PrimaryExecutionPath"> <ListenActivity x:Name="ListenForExtractReadyTimeoutAfterOneWeek"> <EventDrivenActivity x:Name="ListenForExtractIssueReady"> <HandleExternalEventActivity x:Name="ExtractIssueIsReadyForPackagingEventHandler" EventName="ExtractIssueReadyForPackagingEvent" InterfaceType="{x:Type ExtractPackaging.BusinessLogic.IExtractIssuePackagingService}"> <HandleExternalEventActivity.CorrelationToken> <wf0:CorrelationToken Name="ActivityContextGuidCorrelationToken" OwnerActivityName="ExtractIssuePackagingActivity" xmlns:wf0="http://schemas.microsoft.com/winfx/2006/xaml/workflow" /> </HandleExternalEventActivity.CorrelationToken> </HandleExternalEventActivity> <CodeActivity x:Name="SetIsReadyForPackaging" ExecuteCode="SetIsReadyForPackaging_ExecuteCode" /> </EventDrivenActivity> <EventDrivenActivity x:Name="TimoutAfterOneWeek"> <DelayActivity InitializeTimeoutDuration="TimeToWaitForReady_InitializeTimeoutDuration" TimeoutDuration="7.00:00:00" x:Name="TimeToWaitForReady" /> <TerminateActivity x:Name="TerminateWorkflow" Error="Workflow Terminated: Files Still not Available After Wait Duration Exceeded" /> <ThrowActivity x:Name="ThrowTimeoutException" Fault="{ActivityBind ExtractIssuePackagingActivity,Path=TimeoutException}" Enabled="False" FaultType="{x:Type p12:Exception}" xmlns12="clr-namespaceystem;Assembly=mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" /> </EventDrivenActivity> </ListenActivity> <CodeActivity x:Name="SetDoneWaitingForReady" ExecuteCode="SetDoneWaitingForReady_ExecuteCode" /> </SequenceActivity> <SequenceActivity x:Name="KeepAskingIfExtractIssueReadyForPackaging"> <WhileActivity x:Name="WhileNotIsReadyForPackaging"> <WhileActivity.Condition> <RuleConditionReference ConditionName="ExtractIssueIsNotReadyForPackagingAndNotDoneWaitingCondition" /> </WhileActivity.Condition> <SequenceActivity x:Name="WaitAndCallIsReadyAgain"> <CallExternalMethodActivity x:Name="CallIsExtractIssueReadyForPackaging" InterfaceType="{x:Type ExtractPackaging.BusinessLogic.IExtractIssuePackagingService}" MethodName="ExtractIssueIsReadyForPackaging"> <CallExternalMethodActivity.CorrelationToken> <wf0:CorrelationToken Name="ActivityContextGuidCorrelationToken" OwnerActivityName="ExtractIssuePackagingActivity" xmlns:wf0="http://schemas.microsoft.com/winfx/2006/xaml/workflow" /> </CallExternalMethodActivity.CorrelationToken> <CallExternalMethodActivity.ParameterBindings> <WorkflowParameterBinding ParameterName="activityContextGuid"> <WorkflowParameterBinding.Value> <ActivityBind Name="ExtractIssuePackagingActivity" Path="ActivityContextGuid" /> </WorkflowParameterBinding.Value> </WorkflowParameterBinding> <WorkflowParameterBinding ParameterName="extractIssuePackage"> <WorkflowParameterBinding.Value> <ActivityBind Name="ExtractIssuePackagingActivity" Path="ExtractIssuePackage" /> </WorkflowParameterBinding.Value> </WorkflowParameterBinding> </CallExternalMethodActivity.ParameterBindings> </CallExternalMethodActivity> <DelayActivity InitializeTimeoutDuration="LoopDelayBetweenCallsToIsReady_InitializeTimeoutDuration" TimeoutDuration="00:00:00" x:Name="LoopDelayBetweenCallsToIsReady" /> </SequenceActivity> </WhileActivity> </SequenceActivity> </ParallelActivity> <CallExternalMethodActivity x:Name="CallExternalPackageExtractIssue" InterfaceType="{x:Type ExtractPackaging.BusinessLogic.IExtractIssuePackagingService}" MethodName="PackageExtractIssue"> <CallExternalMethodActivity.CorrelationToken> <wf0:CorrelationToken Name="ActivityGuidCorrelationToken" OwnerActivityName="ExtractIssuePackagingActivity" xmlns:wf0="http://schemas.microsoft.com/winfx/2006/xaml/workflow" /> </CallExternalMethodActivity.CorrelationToken> <CallExternalMethodActivity.ParameterBindings> <WorkflowParameterBinding ParameterName="activityContextGuid"> <WorkflowParameterBinding.Value> <ActivityBind Name="ExtractIssuePackagingActivity" Path="ActivityContextGuid" /> </WorkflowParameterBinding.Value> </WorkflowParameterBinding> <WorkflowParameterBinding ParameterName="extractIssuePackageXmlString"> <WorkflowParameterBinding.Value> <ActivityBind Name="ExtractIssuePackagingActivity" Path="ExtractIssuePackageXmlString" /> </WorkflowParameterBinding.Value> </WorkflowParameterBinding> </CallExternalMethodActivity.ParameterBindings> </CallExternalMethodActivity> <ListenActivity x:Name="WaitForResonseFromExternalCall"> <EventDrivenActivity x:Name="eventDrivenActivity1"> <HandleExternalEventActivity Invoked="OnExtractIssuePackaged" x:Name="handleExternalEventActivity1" EventName="ExtractIssuePackaged" InterfaceType="{x:Type ExtractPackaging.BusinessLogic.IExtractIssuePackagingService}"> <HandleExternalEventActivity.CorrelationToken> <wf0:CorrelationToken Name="ActivityGuidCorrelationToken" OwnerActivityName="ExtractIssuePackagingActivity" xmlns:wf0="http://schemas.microsoft.com/winfx/2006/xaml/workflow" /> </HandleExternalEventActivity.CorrelationToken> </HandleExternalEventActivity> </EventDrivenActivity> <EventDrivenActivity x:Name="eventDrivenActivity2"> <DelayActivity TimeoutDuration="00:00:10" x:Name="ExternalEventTimeout" /> <CodeActivity x:Name="RaiseTimeoutException" ExecuteCode="RaiseTimeoutException_ExecuteCode" /> </EventDrivenActivity> </ListenActivity> <CodeActivity x:Name="ExtractIssuePackagingActivityComplete" ExecuteCode="ExtractIssuePackagingActivityComplete_ExecuteCode" /> <FaultHandlersActivity x:Name="faultHandlersActivity1"> <FaultHandlerActivity x:Name="GenericFaultHandler" FaultType="{x:Type p6:Exception}" xmlns6="clr-namespaceystem;Assembly=mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> <CodeActivity x:Name="HandleFaultCode" ExecuteCode="HandleFaultCode_ExecuteCode" /> </FaultHandlerActivity> </FaultHandlersActivity> </SequenceActivity> using System; using System.ComponentModel; using System.ComponentModel.Design; using System.Collections; using System.Drawing; using System.Workflow.ComponentModel.Compiler; using System.Workflow.ComponentModel.Serialization; using System.Workflow.ComponentModel; using System.Workflow.ComponentModel.Design; using System.Workflow.Runtime; using System.Workflow.Activities; using System.Workflow.Activities.Rules; using System.Configuration; using System.Diagnostics; namespace ExtractPackaging.BusinessLogic { public partial class ExtractIssuePackagingActivity : SequenceActivity { private static TraceSource traceSource = new TraceSource("ExtractPackaging.BusinessLogic.ExtractIssuePackagingActivity"); private DateTime dateTimePackagingStarted = DateTime.Now; public DateTime DateTimePackagingStarted { get { return dateTimePackagingStarted; } set { dateTimePackagingStarted = value; } } private bool allFilesReadyForPackaging = false; public bool AllFilesReadyForPackaging { get { return allFilesReadyForPackaging; } set { allFilesReadyForPackaging = value; } } private DateTime datetimeSentToConcretePackager; public DateTime DateTimeSentToConcretePackager { get { return datetimeSentToConcretePackager; } set { datetimeSentToConcretePackager = value; } } public static DependencyProperty ExtractIssuePackageProperty = System.Workflow.ComponentModel.DependencyProperty.Register( "ExtractIssuePackage", typeof(WebServicesFramework.BusinessEntities.ExtractIssuePackage), typeof(ExtractIssuePackagingActivity)); [Description("The ExtractIssuePackage for which to fulfill the packaging requst")] [Category("ExtractIssuePackaging")] [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)] public WebServicesFramework.BusinessEntities.ExtractIssuePackage ExtractIssuePackage { get { return ((WebServicesFramework.BusinessEntities.ExtractIssuePackage)(base.GetValue(ExtractIssuePackagingActivity.ExtractIssuePackageProperty))); } set { base.SetValue(ExtractIssuePackagingActivity.ExtractIssuePackageProperty, value); } } public static DependencyProperty ExtractIssuePackageGuidProperty = System.Workflow.ComponentModel.DependencyProperty.Register("ExtractIssuePackageGuid", typeof(System.String), typeof(ExtractIssuePackagingActivity)); [Description("The ExtractIssuePackageGuid")] [Category("ExtractIssuePackaging")] [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)] public String ExtractIssuePackageGuid { get { return ((System.String)(base.GetValue(ExtractIssuePackagingActivity.ExtractIssuePackageGuidProperty))); } set { base.SetValue(ExtractIssuePackagingActivity.ExtractIssuePackageGuidProperty, value); } } [Description("ActivityContextGuid")] [Category("Activity")] [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)] public string ActivityContextGuid { get { return ((string)(base.GetValue(Activity.ActivityContextGuidProperty).ToString())); } } [Description("TimeoutException")] [Category("ExtractPackaging")] [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)] public Exception TimeoutException { get { return new Exception("ExtractPackaging.BusinessLogic.ExtractIssuePackagingActivity.TimeoutException"); } } public static DependencyProperty IsReadyForPackagingProperty = System.Workflow.ComponentModel.DependencyProperty.Register( "IsReadyForPackaging", typeof(bool), typeof(ExtractIssuePackagingActivity)); [Description("Indicates if the current extract is ready for packaging")] [Category("ExtractIssuePackaging")] [Browsable(true)] [DefaultValue(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)] public bool IsReadyForPackaging { get { return ((bool)(base.GetValue(ExtractIssuePackagingActivity.IsReadyForPackagingProperty))); } set { base.SetValue(ExtractIssuePackagingActivity.IsReadyForPackagingProperty, value); } } public static DependencyProperty DoneWaitingForReadyProperty = System.Workflow.ComponentModel.DependencyProperty.Register( "DoneWaitingForReady", typeof(bool), typeof(ExtractIssuePackagingActivity)); [Description("Indicates if the workflow is done waiting for the Extract Issue to be ready for packaging")] [Category("ExtractIssuePackaging")] [Browsable(true)] [DefaultValue(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)] public bool DoneWaitingForReady { get { return ((bool)(base.GetValue(ExtractIssuePackagingActivity.DoneWaitingForReadyProperty))); } set { base.SetValue(ExtractIssuePackagingActivity.DoneWaitingForReadyProperty, value); } } public static DependencyProperty ExtractIssuePackageXmlStringProperty = System.Workflow.ComponentModel.DependencyProperty.Register( "ExtractIssuePackageXmlString", typeof(string), typeof(ExtractIssuePackagingActivity)); [Description("Xml representation of the ExtractIssuePackage property")] [Category("ExtractIssuePackaging")] [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)] public string ExtractIssuePackageXmlString { get { return ((string)(base.GetValue(ExtractIssuePackagingActivity.ExtractIssuePackageXmlStringProperty))); } set { base.SetValue(ExtractIssuePackagingActivity.ExtractIssuePackageXmlStringProperty, value); } } public static DependencyProperty PackagedEvent = DependencyProperty.Register("Packaged", typeof(EventHandler), typeof(ExtractIssuePackagingActivity)); [Description("ExtractIssue Packaged")] [Category("ExtractIssuePackaging")] [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)] public event EventHandler Packaged { add { base.AddHandler(ExtractIssuePackagingActivity.PackagedEvent, value); } remove { base.RemoveHandler(ExtractIssuePackagingActivity.PackagedEvent, value); } } private WebServicesFramework.BusinessEntities.Shipment shipment; public WebServicesFramework.BusinessEntities.Shipment Shipment { get { return this.shipment; } set { this.shipment = value; } } private ExtractIssuePackagedEventArgs extractIssuePackagedEventArgs = default(ExtractPackaging.BusinessLogic.ExtractIssuePackagedEventArgs); public ExtractIssuePackagedEventArgs ExtractIssuePackagedEventArgs { get { return this.extractIssuePackagedEventArgs; } } private void AcceptRequest_ExecuteCode(object sender, EventArgs e) { string activityContextGuid = base.GetValue(Activity.ActivityContextGuidProperty).ToString(); traceSource.TraceEvent( TraceEventType.Information, 1, "AcceptRequest_ExecuteCode: ActivityContextGuid = " + activityContextGuid); } private void RaiseTimeoutException_ExecuteCode(object sender, EventArgs e) { traceSource.TraceEvent( TraceEventType.Warning, 1, "RaiseTimeoutException_ExecuteCode"); throw new Exception("ExtractPackaging.BusinessLogic.ExtractIssuePackagingActivity.RaiseTimeoutException_ExecuteCode"); } private void OnExtractIssuePackaged(object sender, ExternalDataEventArgs e) { string activityContextGuid = ((ExtractIssuePackagedEventArgs)e).ActivityContextGuid; traceSource.TraceEvent( TraceEventType.Information, 1, "OnExtractIssuePackaged: ActivityContextGuid = " + activityContextGuid); string xmlString = ((ExtractIssuePackagedEventArgs)e).ExtractIssuePackageXmlString.ToString(); ExtractIssuePackageXmlString = xmlString; ExtractIssuePackage = WebServicesFramework.BusinessEntities.ExtractIssuePackage.FromXmlString(xmlString); WebServicesFramework.BusinessEntities.Manager manager = new WebServicesFramework.BusinessEntities.Manager( WebServicesFramework.DataAccess.Manager.Engine); int extractIssuePackageIndex; extractIssuePackageIndex = manager.ShipmentHelper.GetExtractIssuePackageIndexByGuid( this.Shipment, ExtractIssuePackage.ExtractIssuePackageGuid); if (extractIssuePackageIndex == -1) { extractIssuePackageIndex = manager.ShipmentHelper.GetExtractIssuePackageIndexByData( this.Shipment, ExtractIssuePackage.ExtractId, ExtractIssuePackage.IssueDate, ExtractIssuePackage.PackagingSpecificationId); } shipment.ExtractIssuePackages[extractIssuePackageIndex] = ExtractIssuePackage; } private void ExtractIssuePackagingActivityComplete_ExecuteCode(object sender, EventArgs e) { string activityContextGuid = base.GetValue(Activity.ActivityContextGuidProperty).ToString(); traceSource.TraceEvent( TraceEventType.Information, 1, "ExtractIssuePackagingActivityComplete_ExecuteCode: ActivityContextGuid = " + activityContextGuid); traceSource.TraceEvent( TraceEventType.Information, 1, " "); } private void UpdateExtractIssuePackageId_ExecuteCode(object sender, EventArgs e) { string activityContextGuid = base.GetValue(Activity.ActivityContextGuidProperty).ToString(); traceSource.TraceEvent( TraceEventType.Information, 1, "UpdateExtractIssuePackageId_ExecuteCode: ActivityContextGuid = " + activityContextGuid); ExtractIssuePackage.ExtractIssuePackageGuid = new Guid(ExtractIssuePackageGuid); // Don't forget to update the xmlString as well ExtractIssuePackageXmlString = WebServicesFramework.BusinessEntities.ExtractIssuePackage.ToXmlString( ExtractIssuePackage); } private void HandleFaultCode_ExecuteCode(object sender, EventArgs e) { traceSource.TraceEvent( TraceEventType.Error, 1, "HandleFaultCode_ExecuteCode:" + GenericFaultHandler.Fault.ToString()); } private void SetDoneWaitingForReady_ExecuteCode(object sender, EventArgs e) { this.DoneWaitingForReady = true; this.AllFilesReadyForPackaging = true; } private void LoopDelayBetweenCallsToIsReady_InitializeTimeoutDuration(object sender, EventArgs e) { this.LoopDelayBetweenCallsToIsReady.TimeoutDuration = TimeSpan.Parse( ConfigurationManager.AppSettings["ExtractPackaging.BusinessLogic.ExtractIssuePackagingActivity.LoopDelayBetweenCallsToIsReady"]); } private void TimeToWaitForReady_InitializeTimeoutDuration(object sender, EventArgs e) { this.TimeToWaitForReady.TimeoutDuration = TimeSpan.Parse( ConfigurationManager.AppSettings["ExtractPackaging.BusinessLogic.ExtractIssuePackagingActivity.TimeToWaitForReady"]); } private void SetIsReadyForPackaging_ExecuteCode(object sender, EventArgs e) { this.IsReadyForPackaging = true; } private void CallExternalPackageExtractIssue_MethodInvoking(object sender, EventArgs e) { DateTimeSentToConcretePackager = DateTime.Now; } private void ResetCorrelationToke_CodeActivity_ExecuteCode(object sender, EventArgs e) { } } } |
|||||||||||||||||||||||