Skip to main content

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.

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


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.


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

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


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

 

 


Thanks. Question I have is why doesn't FME support the "loop"?
It does, inside a custom transformer 😉

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