I have a .NET component that calls a custom web service and posts some data. At point point in the next 30 days, the service will have my return value ready. I want to be able to poll the service every 2 hours to see if the value is ready. Is there a way to do this in K2?
You could do this using a workflow (in K2 or Visual Studio) and adding an activity that checks the web service and if no result found it increments the wait time and loops back onto itself.
Activities have a start rule that allows you to set the start time for the activity. You could create a workflow datetime data field to use in this rule.
When the workflow starts add an data transfer event to set the data field to current date time.
Then add a new activity and set it's start rule to use a date and add the data field.
Add an event to your activity to poll your web service (I assume you have a smartobject for this?). If you get a result store this in another workflow data field.
Add a data transfer event after the first event and use it to increment the datetime data field by 2 hours. You can use the date time functions for this.
Then draw 2 lines from your activity - one to the next activity in your workflow. The second back loops back onto the same activity. Configure the line rules so that the workflow will loop back only if the poll result data field is empty.
If it was polling every few minutes, with thousands of workflow instances then I would agree with you Nagorskiy. If it is every 2 hours and only a small number of instances then performance will not be impacted.
A server event will work if you have control over the other system and can modify it to action the task (e.g. code using K2 api).