locked
Saving Application parameters using WF4 Instance Store RRS feed

  • Question

  • Hi,

       I have 2 parameters named requestId and workflowName which comes with every request through s service.The service communicates with the workflow framework where I generate an instanceid using WorkflowApplication when the workflow is started.Now I need to store the reuestID,WorkflowName and instanceID in some table(one solution is storing these in an external table through a Data Access layer written by me) so that when another request(again only requestID and workflowName will be sent) comes for Loading then I need to get the instanceid associated with the requestID and workflowName.I want to do it through some WF4 API(may be SQLInstanceStore.Promote - not sure) and don't want to get those custom parameters through some ActivityContext object since my intent here is just to get the instanceid from the requestID and workflowName.Please guide me(if possible please provide some sample).

    Regards,

    Sandip

    Friday, May 18, 2012 5:57 PM

Answers

  • Hi,

    You can use WorkflowApplication.Id property to get the instance id directly if the workflow instance was created by WorkflowApplication.

    http://msdn.microsoft.com/en-us/library/system.activities.workflowapplication.id.aspx

    Then you can store it in external table for later query.

    For the SQLInstanceStore.Promote, you can promote the request and workflowName, then you'll be able to querty the associated instanceId from [System.Activities.DurableInstancing].[InstancePromotedProperties] table in instance store.

    http://msdn.microsoft.com/en-us/library/ee622979

    If you need more information or I misunderstood you, please let me know. Thanks.


    Leo Tang [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Sunday, May 20, 2012 12:52 AM
  • Hi,

    ->As far as Promote is concerned, is there any API provided to get(query) the instanceID from the request and wfName (actually I dont want to write the Data access layer and all and so searching for some direct API for the same).Is that possible?

    In this specific case, there is no API we can call directly to get the instanceID. The possible way to call API here is keep a reference which pointed to the original WorkflowApplcation instance. 

    However, if you host a workflow service via WorkflowServiceHost or IIS, you can configure Content-Based Correlation on requestID and workflowName, then you'll be able to send multiple WCF message to the same workflow instance. In this way, the workflow engine will load the correct workflow instance, you can use a very simple custom activity in the workflow to return the WorkflowInstanceId.

    Get WorkflowInstanceId

    http://msdn.microsoft.com/en-us/library/ee943758.aspx

    Hope this information helps, thanks.


    Leo Tang [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Monday, May 21, 2012 9:04 AM

All replies

  • Hi,

    You can use WorkflowApplication.Id property to get the instance id directly if the workflow instance was created by WorkflowApplication.

    http://msdn.microsoft.com/en-us/library/system.activities.workflowapplication.id.aspx

    Then you can store it in external table for later query.

    For the SQLInstanceStore.Promote, you can promote the request and workflowName, then you'll be able to querty the associated instanceId from [System.Activities.DurableInstancing].[InstancePromotedProperties] table in instance store.

    http://msdn.microsoft.com/en-us/library/ee622979

    If you need more information or I misunderstood you, please let me know. Thanks.


    Leo Tang [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Sunday, May 20, 2012 12:52 AM
  • Hi Leo,

              The external table concept is fine but for the time being I want to omit it.As far as Promote is concerned, is there any API provided to get(query) the instanceID from the request and wfName (actually I dont want to write the Data access layer and all and so searching for some direct API for the same).Is that possible?

    Regards,

    Sandip

    Sunday, May 20, 2012 6:08 AM
  • Hi,

    ->As far as Promote is concerned, is there any API provided to get(query) the instanceID from the request and wfName (actually I dont want to write the Data access layer and all and so searching for some direct API for the same).Is that possible?

    In this specific case, there is no API we can call directly to get the instanceID. The possible way to call API here is keep a reference which pointed to the original WorkflowApplcation instance. 

    However, if you host a workflow service via WorkflowServiceHost or IIS, you can configure Content-Based Correlation on requestID and workflowName, then you'll be able to send multiple WCF message to the same workflow instance. In this way, the workflow engine will load the correct workflow instance, you can use a very simple custom activity in the workflow to return the WorkflowInstanceId.

    Get WorkflowInstanceId

    http://msdn.microsoft.com/en-us/library/ee943758.aspx

    Hope this information helps, thanks.


    Leo Tang [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Monday, May 21, 2012 9:04 AM