Mark Bostleman
Mark Bostleman

Reputation: 2205

WF4 hosted in IIS not persisting

I have a WF4 state machine workflow that I am hosting in IIS. I am trying to add persistence and have added the following to the web.config.

<behaviors>
    <behavior>
        <!-- To avoid disclosing metadata information, set the values below to false before deployment -->
          <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true"/>
          <!-- To receive exception details in faults for debugging purposes, set the value below to true.  Set to false before deployment to avoid disclosing exception information -->
          <serviceDebug includeExceptionDetailInFaults="false"/>
    </behavior>

    <behavior name="WorkflowPersistence">
          <sqlWorkflowInstanceStore
                  connectionString="Data Source=.\SQLExpress;Initial Catalog=InstanceStore;Integrated Security=True;Async=true"
                  instanceEncodingOption="GZip"
                  instanceCompletionAction="DeleteAll"
                  instanceLockedExceptionAction="AggressiveRetry"
                  hostLockRenewalPeriod="00:00:30"
                  runnableInstancesDetectionPeriod="00:00:05" />

          <workflowIdle timeToPersist="00:00:05" timeToUnload="00:00:30"/>
    </behavior>
</behaviors>

I also set the PeristBeforeSend property to true on the SendReplyToReceive of the workflow's initial operation. After calling the initial operation nothing is persisted in the InstancesTable. I've also let the workflow sit idle and nothing is persisted either. There are no exceptions or entries in the event log. All of the service operations run fine. I can run the workflow from beginning to end without errors.

I also set the value of the data source attribute in the connection string to something I know is invalid to get a Sql exception when it tries to connect, but still nothing. So it is either doing a really good job at failing silently or the persistence is not firing at all. I'm probably missing something simple - any ideas?

Upvotes: 1

Views: 219

Answers (1)

Mark Bostleman
Mark Bostleman

Reputation: 2205

The problem was the extra Behavior element in the Behaviors collection. I removed the second Behavior (named WorkflowPersistence) and put its contents in the first Behavior. Then persistence started working.

Upvotes: 1

Related Questions