Home > CRM Deployement, CRM Development, MSCRM General > Waiting/Timed Workflow VS Windows Service

Waiting/Timed Workflow VS Windows Service


Developing some service or workflow to handle some periodic tasks is natural to CRM solutions. Last week, I have been looking for the best way to handle periodic tasks like sending reminders, creating tasks based on date/time, birthday notifies etc.

So I have an entity project schedule and I have thousands of records of this entity where I have to send email reminders. For each record I can have a waiting workflow. So I can have thousands of waiting workflows. While, I can develop a windows service that runs overnight and process records according to criteria and send reminders.

What about performance constraints for hundreds of waiting workflows VS one windows service instance running overnight?

So here are some merits and demerits for both techniques:

1. Workflows can be configurable with no code but we need to create a configuration mechanism for windows service and scheduled tasks.

2. We can control the best time to execute a windows service while workflows fired on the event matching time condition.

3. Any change in the logic can be rolled out with ease in case of windows service during off peak time while waiting workflow remain in waiting as per old logic. So it creates a big issue in case of maintenance.

4. If number of records is high then creating waiting workflows cause a strain on the system and degrade performance as compared to windows service.

5. If there is frequent update operation on the waiting workflow entity then every time a change occur workflow becomes active and then in waiting state. This can cause a strain to the live system.

Although waiting workflows will not consume any CPU or memory resources but overhead of handling change and strain on system during peak hours make them a less favorite as compared to windows service. Personally I feel much control and maintainability in windows service as compared to workflows.

About these ads
  1. December 2, 2008 at 3:43 pm | #1

    I have tried to develop different workflows for CRM 4.0 but it seems difficult when you assign a task or a meeting to a user to take into account the working hours and days of this user!
    E.g. if you define the due date of a meeting as being 2 days after a record is created, and if the record is indeed created a Thursday, then the meeting will be scheduled during the W-E!?!
    How to avoid that?
    Many thanks

  2. Glenn
    December 5, 2008 at 6:02 am | #2

    We are having the same issue with Workflow vs Batch job Pros/Cons to send out alerts. Basically our user base are around 2k thus by using workflows, 2k instances of WF will be created and straining the whole system. The plan will be changing to windows service. But as there are standard templates involved with proper format in WF, how do we go about changing to window service without affecting the output? Users also want to be able to manage the timeline to send those alerts, example 1 day, 3 days etc…any experience to share so i can avoid common pitfalls? Thanks alot!

  3. Selina
    December 12, 2008 at 7:41 pm | #3

    Ayaz,

    I have reps here that have incoming email come in from Fedex.com letting them know their package was delivered. The problem is that every email is attaching automatically many times to the same contact in activity history. I looked at the events in System Jobs and it says ‘ workflow expansion task’ created by system, owned by system. We have never Ssetup a workflow with incoming emails. Any idea why this is happening and how to stop it? We use CRM 4.0 and the Outlook Ciient.
    Thanks!

  4. Ad
    December 14, 2008 at 1:59 pm | #4

    Hi Ayaz,

    Thanks for this explanation. I’m currently in the process of developing an environment where exact the same issue appears. I had it running with 4000+ waiting workflows but am a little worried about the behaviour in a real life system. Do you have some template or so for developing a service that interacts with CRM? I made a couple of interactive plugins, but having a hard time to find out how to make something that is not running interactive. Thanks for you cooperation!
    Regards,
    Ad.

  5. December 14, 2008 at 8:28 pm | #5

    Hi Ad,

    It is not so complex to write a simple windows service. You can find a ll info at http://msdn.microsoft.com/en-us/magazine/cc301845.aspx

    Just create a windows service project using template projects and embed CRM specific logic using SDK recommendations.

    Windows service executes every minute so you need to define a process to compare time and then execute it.

  6. December 14, 2008 at 8:32 pm | #6

    Hi Selina,

    There must be some workflow defined on activity that is executed whenever a new email is received. This seems to be an automatic workflow or a plugin.

  7. December 14, 2008 at 8:44 pm | #7

    Hi Glenn,

    No doubt, work flow provide some really handy out of the box features. In windows service, you need to program everything and they are lengthy but more controlled.

    In your case, you can use the windows service and workflows in conjuction. Like you can make your workflow to fire manually and remove waiting conditions. Just a clean workflow to send alerts as per standard template and then in windows service you can program the event and time to fire that workflow. You can fire a workflow using code. Look into SDK and find the relative code. You can even fire a workflow from plugin/javascript. You can fine the code on internet easily.

    So you workflow is having the all functionality and your windows service will be having the event and execution code.

  8. Selina
    December 16, 2008 at 5:19 pm | #8

    Thank you will definetly look into that!

  9. December 23, 2008 at 12:49 am | #9

    Hi Ayas

    We have a problem that work flows just do not fire. (Workflows do not flow, if you will excuse the pan).

    What we find intriguing is that when you look at CRM -> Settings -> System jobs you see familiar entries with system event, workflow extension task and at status of waiting. The wait is “forever”.

    We applied hot fix KB957701, it did not help.

    Avner

  10. December 23, 2008 at 1:50 am | #10

    Please have a look into trace entries for CRMAsync Service trace file.

    Does your workflow has any custom activity?
    What about Waiting criteria?

  11. July 15, 2011 at 10:50 pm | #11

    Nice read, I just passed this onto a colleague who was doing a little research on that. And he just bought me lunch because I found it for him smile Thus let me rephrase that: Thanks for lunch!

  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

Join 58 other followers

%d bloggers like this: