Newbie Question - Poll web service

  • 26 August 2016
  • 3 replies
  • 2 views

Badge +1

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


3 replies

Userlevel 1
Badge +8

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.

Badge +3
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.


Userlevel 1
Badge +8

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

Reply