Campaign using workflow

Hi,
I am starting on an assignment where I have to implement a solution for running a campaign. As I was looking for options I came across windows workflow which looks very interesting but I need help on how I can model my requirements using the same

Assume the following steps in the campaign
1. Start
2. Run a query & act (for each row in the resultset perform an action like send email)
3. On Event
3a.1) Response received
3a.2) Generate coupon & Send email
3a.3) End

3b.1) Wait for condition to be true (elapsed time is X hours/days)
3b.2) Run a query & act (find those who did not respond and send reminders
3b.3) End


Questions
1. I am assuming that the definition of the campaign (in terms of number of steps, queries and actions to perform) can be expressed completely in XAML and a host like asp.net will be able to run it.

2. Assume that step 2 results in 100000 rows, now as the workflow iterates and performs an action on (say) the 1000th row, its possible that a response for the first row is received. So effectively, two parts (2 and 3a.1) of the same workflow are executing concurrently, is that possible

3. How do I plan for scale, should I plan for some kind of task allocator so that if the number of rows in step 2 is really large then the processing gets distributed across multiple workflows in different hosts

4. Is it ok to model a Campaign as a single workflow vs. a Campaign as mutliple workflows where most of the workflows trigger on an event

Thanks for your advice
Pranav



Answer this question

Campaign using workflow

  • IndustrialGroup

    I was searching the forum for another post and found your question. I don't know if you have found any answers yet but I thought I'd throw out my $.02. I am building a similar system using workflows that will be responding to incoming messages. The design that I'm using will create a single workflow per request so as to reduce the complexity and operational overhead of any single workflow.

    So, I would recommend running the query and instead of using one huge workflow break each process into individual workflows. Then instead of 100k records in the state of one workflow you have 100k workflows each persisted and waiting for some activity. This will perform and scale much better since you can spread the processing of those individual instances among many runtime instances on separate servers. Then use a listen activity with your delay and an event handler that you call whenever you get a response from the campaign.

    I presented a much smaller-scaled demo at a code camp last summer that might be of interest as far as having a controller workflow and individual workflows waiting for some external response or a delay. You can download it from this post on my blog.

    Hope this helps!



  • Scott Allison

    Yes, you can use XAML only workflow and host it in ASP.Net. There are quite a few samples on the community site that demonstrate how to host WF inside ASP.Net. You might need to write a custom root activity to define workflow properties if you need to pass parameters to the workflow at runtime.

    As for scalability, I also think you should write one simple workflow to handle sending email and receiving response for one single person. You ASP.Net app could perform the database query and create 100K instances of the workflow. These instances will be persisted in the persistence database and only loaded back into memory when the response comes back, or if you have a timer to track expiration, when the timer expires. These workflow instances can be farmed out to run on multiple web servers, all of which accessing the same persistence database. The default SqlPersistenceService will lock the instance when it's re-loaded so only one workflow runtime can run a particular instance at a time,

    Shelly Guo


  • Campaign using workflow