워크플로 인스턴스가 Receive 동작을 사용하여 메시지가 전달될 때까지 기다리는 경우와 같이 워크플로는 일부 외부 자극에 의해 다시 시작되어야 하는 책갈피를 만나면 유휴 상태가 됩니다. WorkflowIdleBehavior 는 서비스 인스턴스가 유휴 상태가 되는 시점과 인스턴스가 지속되거나 언로드되는 시점 사이의 기간을 지정할 수 있는 동작입니다. 이러한 기간을 설정할 수 있는 두 가지 속성이 포함되어 있습니다. TimeToPersist 는 워크플로 서비스 인스턴스가 유휴 상태가 되는 때와 워크플로 서비스 인스턴스가 지속되는 때 사이의 시간을 지정합니다. TimeToUnload 는 워크플로 서비스 인스턴스가 유휴 상태가 되는 때와 워크플로 서비스 인스턴스가 언로드되는 때 사이의 시간을 지정합니다. 여기서, 언로드란 인스턴스를 인스턴스 스토어에 유지하고 메모리에서 제거하는 것을 의미합니다. 이 항목에서는 구성 파일에서 WorkflowIdleBehavior 를 구성하는 방법에 대해 설명합니다.
WorkflowIdleBehavior를 구성하려면
다음 예제와 같이
<workflowIdle>
요소를<behavior>
요소 내의<serviceBehaviors>
요소에 추가합니다.<behaviors> <serviceBehaviors> <behavior name=""> <workflowIdle timeToUnload="0:05:0" timeToPersist="0:04:0"/> </behavior> </serviceBehaviors> </behaviors>
timeToUnload
특성은 워크플로 서비스 인스턴스가 유휴 상태가 되는 때와 워크플로 서비스 인스턴스가 언로드되는 때 사이의 시간을 지정합니다.timeToPersist
특성은 워크플로 서비스 인스턴스가 유휴 상태가 되는 때와 워크플로 서비스 인스턴스가 지속되는 때 사이의 시간을 지정합니다.timeToUnload
의 기본값은 1분입니다.timeToPersist
의 기본값은 MaxValue입니다. 유휴 인스턴스를 메모리에 유지하지만 견고성을 위해 지속시키려는 경우timeToPersist
<timeToUnload
입니다. 유휴 인스턴스가 언로드되지 않도록 하려면timeToUnload
를 MaxValue로 설정합니다. WorkflowIdleBehavior대한 자세한 내용은 워크플로 서비스 호스트 확장성 참조하세요.참고 항목
위의 샘플에서 사용하는 구성은 단순화된 구성입니다. 자세한 내용은 간단한 구성을 참조하세요.
코드에서 유휴 동작을 변경하려면
다음 예제에서는 프로그래밍 방식으로 지속 및 언로드 전에 대기할 시간을 변경합니다.
// Code to create a WorkFlowServiceHost is not shown here. // Note that SqlWorkflowInstanceStore is in the System.Activities.DurableInstancing.dll. host.DurableInstancingOptions.InstanceStore = new SqlWorkflowInstanceStore(connectionString); WorkflowIdleBehavior alteredBehavior = new WorkflowIdleBehavior { // Alter the time to persist and unload. TimeToPersist = new TimeSpan(0, 4, 0), TimeToUnload = new TimeSpan(0, 5, 0) }; //Remove the existing behavior and replace it with the new one. host.Description.Behaviors.Remove<WorkflowIdleBehavior>(); host.Description.Behaviors.Add(alteredBehavior);
' Code to create a WorkflowServiceHost not shown here. ' Note that SqlWorkflowInstanceStore is in the System.Activities.DurableInstancing.dll host.DurableInstancingOptions.InstanceStore = New SqlWorkflowInstanceStore(connectionString) ' Create a new workflow behavior. Dim alteredBehavior As WorkflowIdleBehavior = New WorkflowIdleBehavior() ' Alter the time to persist and unload. alteredBehavior.TimeToPersist = New TimeSpan(0, 4, 0) alteredBehavior.TimeToUnload = New TimeSpan(0, 5, 0) ' Remove the existing behavior and add the new one. host.Description.Behaviors.Remove(Of WorkflowIdleBehavior)() host.Description.Behaviors.Add(alteredBehavior)