JeffJeff
Novice

Newbie Question - Poll web service

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?

 

Thanks,

-Jeff

0 Kudos
Reply
3 Replies
Andrew_Blinco
Apprentice

Re: Newbie Question - Poll web service

Hi Jeff

 

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.

0 Kudos
Reply
Nagorskiy
Apprentice

Re: Newbie Question - Poll web service

Jeff, its bad decision to implement pooling in workflow because of perfomance.
If you have a lot of process your k2 server will busy.

I recommend assign server task. So, workflow will pause until some external system complete server task in k2. If external system cant complete task in k2 you can implement pooling in windows service/scheduler with powershell or whatever.


0 Kudos
Reply
Andrew_Blinco
Apprentice

Re: Newbie Question - Poll web service

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). 

0 Kudos
Reply