SharePoint Developer Center > SharePoint Products and Technologies Forums > SharePoint - Workflow > calling sharepoint excel web service using custom activity added to the state initialization activity or event driven activity of a state is too slow
Ask a questionAsk a question
 

Questioncalling sharepoint excel web service using custom activity added to the state initialization activity or event driven activity of a state is too slow

  • Monday, November 02, 2009 10:31 AMMohammadJizi Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    hi all

    i wish anyone could help me in this problem

    i have a state machine workflow deployed on a list on sharepoint

    in the state machine worklfow i have:

    1-five states
       a-the first state is the initial state of the workflow
       b-the second state, the third state and the fourth state are the states that i create a task in them and wait for the task to be changed then i complete the task
       c-the fifth state is the final state of the workflow

    2-in the second,third state and fourth state i have:
       a-state initialization activity
       b-event driven activity
       c-state finalization activity

    3-in the state initialization i have:
       a-create task with content type
       b- custom activity that calls a web service

    4-in the event driven i have :
      a-on task changed activity
      b-set state activity

    5-in the state finalization i have
       a-complete task activity


    lets talk about what i am doing in the custom activity:

    in the custom activity i am calling a class located in a dll file that calls sharepoint excel web service

    then i takes all the fields of the item the workflow is running on

    and fill the cells in the excel sheet (previously created ) with the values from the fields

    1st problem:
    -------------------------------------------------------------------------------------------
    my problem is that calling the excel service from this custom activity in the state initialization of the second state it takes about 15 to 20 seconds to finish executing

    while calling the excel service from this custom activity in the state initialization of the third state and fourth state it takes more than a minute to finish executing

    -------------------------------------------------------------------------------------------



    2nd problem:
    ------------------------------------------------------------------------------------------
    then i decided to change the location of my custom activity. i added it in the event driven activity after the on task changed activity

    now what happens is when calling the excel service from this custom activity in the event driven activity in all the states took more than a minute to finish executing
    ------------------------------------------------------------------------------------------

    so what is happening is that only in the state initialization of the second state calling excel web service is taking 15 to 20 seconds to finish

    questions:
    ---------------------------------------------------------------------------------
    1-can anyone explain for me why this problem is happeneing?
    2-why only calling excel web service in the state initialization of the second state is taking the less time?
    is it because the second state is the state that will executes directly after the initial state of the workflow?
    ---------------------------------------------------------------------------------


    than you very much

All Replies

  • Monday, November 02, 2009 2:26 PMCharlie Holland Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    What event are you handling in the event driven activity? It may be that the action is being run by SPTimerV3 rather than SharePoint, also you'll have a lag before the event kicks in.


    Ch. - My Blog
  • Monday, November 02, 2009 3:38 PMMohammadJizi Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     

    hi thank you for you reply

    in the event driven activity i am handling the on task changed event

    and what do you mean by :It may be that the action is being run by SPTimerV3 rather than SharePoint, also you'll have a lag before the event kicks in


    note: you should read my post again because i have edit it because i have found a new problem
  • Monday, November 02, 2009 7:20 PMCharlie Holland Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    While the workflow is running it isn't neccesarily stored in memory. The workflow runtime will serialize and deserialize the information to/from the database if it's not currently in use. This is especially the case for state machine workflows because they are largely event driven so they spend a lot of time waiting for somthing to happen before any code actually executes. Certain workflow actions, such as the timer action, make use of the Sharepoint timer service (SPTimerV3). For the timer action basically a job is created that deserializes the workflow after a specific period of time and continues execution. Once the timer job is created the workflow is serialized until the timer or another event 'wakes' it up.


    In your case I think the reason for the delay is this:

    When you call your function in your state initializtion code the workflow has already been deserialized from the database and is up and running in memory. However, when you call the code in any event handler, ther event gets triggered, which is passed top the workflow engine, which in turn deserializes the workflow state from the database then executes your code. I think all of this extra processing is what's causing the difference in timing.

    There's not really a lot you can do about this other than upgrade your hardware so that the serialization/deserializtion process is quicker.

    Hope this explains the problem a bit better, sorry I can't provide a solution.
    Ch. - My Blog
  • Tuesday, November 03, 2009 8:21 AMMohammadJizi Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    thanks for your reply

    it was very helpful

    but my problem also is happening if i execute the custom activity in the state initialization of a state . it aslo took more than a minute.

    only thewhen executing the custom activity in the state initialization of the first state ,which is after the initial state of the workflow, will
    take 20 secs.

    so i decided to remove all the activities and only keep the custom activity i am using .

    so my workflow become consists of:

    1-five states
       a-the first state is the initial state of the workflow
       b-the second state, the third state and the fourth state are the states that i execute my custom activity that calls the sharepoint excel service
       c-the fifth state is the final state of the workflow

    2-in the second,third state and fourth state i have:
       a-state initialization activity

    3-in the state initialization i have:
      a- custom activity that calls a sharepoint Excel web service


    now every state took about 20 secs when executing my custom activity that calls the sharepoint excel service

    conclusion:

    what i concluded that if i created a workflow with states and in every state initialization of a state i call my custom activity it took 20 secs to finish exceuting while if i add a create task with content type activity before my custom activity. then my custom activity will take more than 1 minute to finish executing.

    questions:

    1-why when i put the create task with content type activity in the state initialization of a state before my custom activity, my custom activity take more than 1 minute to finish execute ?
  • Wednesday, November 04, 2009 10:46 AMMohammadJizi Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     

    hey where are the GURUS of sharepoint workflow

    it is urgent to me to solve this problem

    thanks