简体   繁体   中英

Can a single Windows Workflow instance be configured to use multiple databases?

We are using Windows Workflow engine for our .NET 4.5 based ASP.Net application. The Windows Workflow application is deployed as an IIS application and is configured for SQL persistence with the connection information specified in the web.config file. We now want to move this application (along with the Workflow engine) to the cloud.

Regarding this cloud migration, we are somewhat confident about the following decisions that we made for our ASP.Net (non Windows Workflow) application:

  • Every customer will have a separate database
  • A single web application will serve multiple customers

However, we are not very sure on how to migrate the Windows Workflow application to the cloud. As I understand, we have the following choices:

  1. Use a single instance/single database approach. In this approach, we will have a single workflow instance and a single workflow database schema serve multiple customers.
  2. Use a multiple instance/multiple database approach. In this approach, we will have a separate IIS application along with a separate database schema for each customer.
  3. Use a single instance/multiple database approach. In this approach, we will have a single workflow instance that will be capable of talking to multiple workflow persistence databases (one per customer).

With #1, we are primarily concerned about the performance as the load increases on this single database. With #2, the concern is web application scalability since it does not seem right to have 1000 web applications for 1000 customers.

That leaves us with option #3, which we think is the right way to go. However, we are not sure if this can be done in Windows Workflow or not.

So the question is, can a single instance of Windows Workflow web application be somehow configured or programmed to talk to multiple SQL persistence databases? If yes, how can we achieve that?

Thanks!

I never do it myself, but I think that you can do this by implementing your own PersistenceService . To do this, derive from WorkflowPersistenceService abstract class, which has a methods like SaveWorkflowInstanceState / LoadWorkflowInstanceState .

In this methods you can access WorkflowInstanceId property of workflow. I think that you can use this property to decide where to store this specific workflow instance. To be able to load (restore) workflow from proper database you will need to implement some mapping like this: WorkflowInstanceId : DatabaseId .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM