Question

Poll REST Service until value changes

  • 21 June 2018
  • 7 replies
  • 14 views

Badge

Good afternoon,

How would I poll a REST Service, check the value of a attribute (e.g. status), sleep if the attribute is not yet "completed" and then retry? (Ideally I'd implement a short-circuit if the time is exceeded, e.g. expose a attribute in Python and add a Tester).

In this diagram, it seems FME explicitly prevents the possibility of a looping structure?

Do I need to either:

 

Cheers.


7 replies

Userlevel 2
Badge +19

Yes, you can't build loops in the main workspace. But you can create them inside a Custom Transformer.

 

http://docs.safe.com/fme/2017.1/html/FME_Desktop_Documentation/FME_Workbench/Workbench/custom_transformer_creating.htm

 

http://docs.safe.com/fme/2017.1/html/FME_Desktop_Documentation/FME_Workbench/Workbench/transformers_custom_looping.htm

Userlevel 4

I agree with @oscard.

An alternative to a looping transformer would be to do the polling inside a PythonCaller, using e.g. the urllib module.

Badge
Thanks. Question I have is why doesn't FME support the "loop"?
Badge +5

I've done something similar with a Creator that creates a large number of features going into a Decelerator that controls the sleep time.

Badge

I've done something similar with a Creator that creates a large number of features going into a Decelerator that controls the sleep time.

Unfortunately the time will depend on the file size...

 

 

Userlevel 4
Thanks. Question I have is why doesn't FME support the "loop"?
It does, inside a custom transformer ;-)
Userlevel 3
Badge +17

In this Workspace I put an example solution. It calls www.google.com every 10sec until the http status code is 200. Handy to use when your internet seems down.

wait-for-status-ready.fmw

In your case the Flattener and Exploder come inside the 'Wait for status ready' transformer in between the Http-caller and the Tester. I would recommend to use a Decelerator to trottle the calls. Else the server is busy answering your status request in stead of processing your data. And most of the time you just want the process to finish automagically and the delay is not significant.

Reply