jhatcher9999
jhatcher9999

Reputation: 246

.NET Workflow 4 Create a Custom Persistence Store that is used by a WCF-enabled Workflow

I am wanting to use WF 4 to as the workflow engine for my project. The activity that I'm using WF for is long-running (could happen over weeks or months), so I want it to use a persistence store. I also want to take advantage of durable delays so that I could have notifications that are sent days after the fact. All my research points me in the direction of using workflow services hosted in IIS with AppFabric on top.

I tested this scenario on my local machine, and it works great. My workflow persists, and my delays kick off when I want them to. I have one problem: the architecture defined at my company doesn't allow the service layer (the WCF service hosted in IIS) to talk directly to the database layer. I thought that a good option for getting around this would be to write a custom instance store that would route calls to the persistence DB through a data access layer. I can find plenty of examples of implementing a custom instance store through code (i.e., workflowApplication.InstanceStore = customInstanceStore). But, the WCF-enabled service has no code, and I can't find any examples that let me configure the persistence store through the web.config. I tried creating a PersistenceProvider/PersistenceProviderFactory and setting that up through the web.config, but that is not allowed.

Does a WCF-enabled workflow host have to use the built-in SQL instance store that talks directly to the DB?

Upvotes: 2

Views: 999

Answers (1)

Mike Perrenoud
Mike Perrenoud

Reputation: 67898

All my research points me in the direction of using workflow services hosted in IIS with AppFabric on top.

That is the correct road to be heading down. IIS serves up the WCF endpoint and the AppFabric installation manages persistence, delays, and monitoring.

Does a WCF-enabled workflow host have to use the built-in SQL instance store that talks directly to the DB?

Not at all, in fact all you should have to do is replace your persistence store type with the one you're used to seeing in the Web.config. So, in the below code snippet you see the SqlWorkflowInstanceStore inside the behavior - put your type in its place. Your type may receive some custom properties, like the connectionString so you'll want to configure it as such.

<configuration>
  <system.serviceModel>
    <behaviors>
      <serviceBehaviors>
        <behavior name=”myBehavior”>
          <SqlWorkflowInstanceStore connectionString=”Data Source=myDatatbaseServer;Initial Catalog=myPersistenceDatabase”>
        </behavior>
      </serviceBehaviors>
    <behaviors>
  </system.serviceModel>
</configuration>

Upvotes: 1

Related Questions