Jaa


How To: Configure Instance Store, Query, and Control Providers

After you have finished developing a store, query, or control provider, you need to register the provider by using the steps described in How To: Register Custom Providers. The installation program of the provider should perform steps similar to the ones described in the following list:

  1. Run script files that create the physical instance store and install provider assemblies on the computer.

  2. Add a definition for the instance store provider to the root Web.config file.

  3. Add a definition for the instance store to a Web.config file.

  4. Configure the instance store behavior for a service in the configuration file associated with the service.

The rest of this topic describes how to add a provider definition, store definition, and store behavior that uses the store to a configuration file.

Instance Store Provider Definition

You must define an instance store provider in the root Web.config file for each type of instance store you plan to use with Microsoft AppFabric 1.1 for Windows Server. The instance store provider definition contains the following parameters:

Note

The web.config file for the computer can be found in two different places: in the <drive>\Windows\Microsoft.NET\Framework\v4.0.30319\Config folder, and in the directory where the application is placed.

  • Name. Specifies the name of the instance store provider. This parameter is a mandatory parameter.

  • Store Provider. Specifies the fully-qualified name of the type that implements the InstanceStoreProvider abstract class and the assembly that contains the type. This parameter is a mandatory parameter.

  • Query Provider. Specifies the fully-qualified name of the type that implements the InstanceQueryProvider abstract class and the assembly that contains the type. This parameter is a mandatory parameter. If the store does not implement a query provider, you can specify an empty string as a value for this parameter.

  • Control Provider. Specifies the fully-qualified name of the type that implements the InstanceControlProvider abstract class and the assembly that contains the type. This parameter is a mandatory parameter. If the store does not implement a control provider, you can specify an empty string as a value for this parameter.

The AppFabric installation program adds a store provider definition for the instance store provider for the SQL Workflow Instance Store as shown in the following example.

<configuration>
    <microsoft.applicationServer>
        <persistence>
            <instanceStoreProviders>
                <add name="sqlStoreProvider"
                    storeProvider="Microsoft.ApplicationServer.StoreProvider.Sql.SqlWorkflowInstanceStoreFactory, Microsoft.ApplicationServer.StoreProvider, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
                    queryProvider="Microsoft.ApplicationServer.StoreManagement.Sql.Query.SqlInstanceQueryProvider, Microsoft.ApplicationServer.StoreManagement, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
                    controlProvider="Microsoft.ApplicationServer.StoreManagement.Sql.Control.SqlInstanceControlProvider, Microsoft.ApplicationServer.StoreManagement, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
            </instanceStoreProviders>
        </persistence>
    </microsoft.applicationServer>
</configuration>

During the installation of your custom instance store provider, you should add the store provider definition to the root Web.config file similar to how the AppFabric installation adds the definition for the SQL instance provider. As you can see in the preceding example, the provider definition is part of the Microsoft AppFabric 1.1 for Windows Server configuration section (Microsoft.ApplicationServer). Therefore, you should install AppFabric before installing your custom store providers. If you install a store provider before installing AppFabric you must manually add the corresponding store provider configuration sections to the root Web.config file. And when you uninstall AppFabric, the entire Microsoft.ApplicationServer section is removed. You may want to remove the custom instance store provider (not the definition, but the assembly containing the store provider type) before or after AppFabric is uninstalled.

Instance Store Definition

An instance store definition defines a store of a specific type. A store definition contains the following parameters:

  1. Name. Specifies the name of the instance store. This parameter is a mandatory parameter. The value of this parameter can be an empty string.

  2. Description. Specifies the description of the instance store. This parameter is an optional parameter. The default value for this parameter is an empty string.

  3. Store Provider. Specifies the name of the store provider for the instance store. This parameter is a mandatory parameter.

  4. Additional attributes. Specifies optional attributes that are represented as name-value pairs. A store address (such as a connection string for the SQL instance store provider) must be defined through one of these parameters. Otherwise the Workflow Management Service (WMS) won't be able to connect to the store.

The following example shows instance stores defined in the root Web.config file. You will need to add any custom instance store in a similar way.

<configuration>
    <microsoft.applicationServer>
        <persistence>
            <instanceStores>
                <add name="storeA"
                    provider="sqlStoreProvider"
                    connectionStringName="storeA-str" />
                <add name="storeB"
                    provider="sqlStoreProvider"
                    connectionStringName="storeB-str" />
                <add name="storeC"
                    provider="MyStoreProvider"
                    MyAddressStringName="storeC-str"
                    value1="rrr"
                    value2="sss"
                    value3="ttt" />
            </instanceStores>
        </persistence>
    </microsoft.applicationServer>
</configuration>

A store defined at a higher scope is inherited by lower scopes automatically. It is possible to remove the inherited store definition from a scope by using the <remove /> or </clear> element.

Instance Store Behavior Extension

You should define a behavior extension element for the instance store so that a user can associate a service with your instance store. The AppFabric installation adds the following behavior extension element to the machine.config file so that you can use sqlWorkflowInstanceStoreBehavior with your service. You need to add the definition for your store behavior in a similar manner during the installation of the store provider.

<system.serviceModel>
    <extensions>
        <behaviorExtensions>
            <add name="sqlWorkflowInstanceStore" type="System.ServiceModel.Activities.Configuration.SqlWorkflowInstanceStoreElement, System.ServiceModel.Activities, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
        </behaviorExtensions>
    </extensions>
</system.serviceModel>

Behavior extensions and section handlers, for example, SqlWorkflowInstanceStore and workflowInstanceControl in the machine.config file, define a nameless behavior with default settings at the root level. Add store-type specific behavior extensions and section handlers to the machine.config file. AppFabric Setup automatically adds the behavior extension for SqlWorkflowInstanceStore and WorkflowInstanceControl behaviors.

Configure a Service to Use the Behavior and the Store

To enable persistence for a service, you need to define an instance store behavior in the Web.config file associated with an application or a service and associate the service with the behavior. The following example shows a sample definition of sqlWorkflowInstanceStore behavior. The value of the connectionStringName is set to an instance store definition, which in turn points to a connection string.

<system.serviceModel>
    <behaviors>
        <serviceBehaviors>
            <behavior name=”myServiceBehavior”>
                <sqlWorkflowInstanceStore
                    connectionStringName="storeA-str"
                    instanceCompletionAction=”DeleteAll”
                    instanceLockedExceptionAction=”NoRetry”
                    hostLockRenewalPeriod=”00:00:30”
                    runnableInstanceDetectionPeriod=”00:00:10” />
            </behavior>
        </serviceBehaviors>
    </behaviors>
</system.serviceModel>

SQL Workflow Instance Store Configuration

The Microsoft AppFabric 1.1 for Windows Server installation program creates a definition for the instance store provider for the SQL Workflow Instance Store in the root Web.config file. You can use the Microsoft AppFabric 1.1 for Windows Server Configuration tool that performs the following functions:

  • Creates a definition of a SQL Workflow Instance Store in the root Web.config file. This definition contains a connection string that refers to the ApplicationServerExtension database.

  • Creates a physical instance store, a SQL Server database named ApplicationServerExtensions.

  • Installs the Workflow Management Service (WMS) as a Windows service. Adds the default WMS configuration section to the root Web.config file with a setting that instructs WMS to automatically discover instance stores.

  2012-09-12