kirankunaparaju / google-api-java-client

Automatically exported from code.google.com/p/google-api-java-client
0 stars 0 forks source link

Support for App Engine asynchronous URL Fetch #871

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Java environment: App Engine

This is a feature request to provide support for App Engine's async URL Fetch 
which is documented here:

https://developers.google.com/appengine/docs/java/javadoc/com/google/appengine/a
pi/urlfetch/URLFetchService#fetchAsync(com.google.appengine.api.urlfetch.HTTPReq
uest)

Support needs to be added to the App Engine client to return a Future:

https://code.google.com/p/google-http-java-client/source/browse/google-http-clie
nt-appengine/src/main/java/com/google/api/client/extensions/appengine/http/UrlFe
tchRequest.java

In addition, the generated libraries need to support handling Future objects.

For example, when using the BigQuery client library:

https://developers.google.com/api-client-library/java/apis/bigquery/v2

You would need to be able to do a streaming insert as documented here, in a way 
which returned a Future:

https://developers.google.com/bigquery/streaming-data-into-bigquery

The benefit is that you may not have to pay additional frontend instance hours 
while waiting for a streaming insert to return, if your App Engine code could 
be doing other work.

Note that there is an HTTPRequest.executeAsync() method available in beta, 
though it has not been added to the App Engine client:

https://code.google.com/p/google-http-java-client/source/browse/google-http-clie
nt/src/main/java/com/google/api/client/http/HttpRequest.java#1071

Original issue reported on code.google.com by jlo...@google.com on 14 Apr 2014 at 6:39

GoogleCodeExporter commented 9 years ago
We don't have a plan for adding async support to this library at the moment. I 
am intending to close this as a low priority feature request, unless there's a 
strong need in the future.

HttpRequest.executeAsync() is a semi-async implementation, i.e., you have to 
poll the status of the future, instead of being called back. In terms of App 
Engine, there isn't a special App Engine client in any way. There's an 
HttpTransport that's AppEngine specific, but the client you use on AppEngine 
extends the same AbstractGoogleJsonClient, which has access to 
HttpRequest.executeAsync(). A small trick is to call 
AbstractGoogleClientRequest.buildHttpRequest().executeAsync().

Original comment by wonder...@google.com on 30 Dec 2014 at 4:25

GoogleCodeExporter commented 9 years ago
#1 - will calling AbstractGoogleClientRequest.buildHttpRequest().executeAsync() 
while using the Appengine Transport use appengine's underlying 
urlfetch.getAsync() or does 
AbstractGoogleClientRequest.buildHttpRequest().executeAsync() just start a new 
thread?

Original comment by al...@streak.com on 30 Dec 2014 at 5:56

GoogleCodeExporter commented 9 years ago
It just starts a new thread and returns a Future.

Original comment by wonder...@google.com on 30 Dec 2014 at 6:52

GoogleCodeExporter commented 9 years ago
Moved to: Issue google-http-java-client:276

Original comment by wonder...@google.com on 2 Jan 2015 at 4:13