(Migrated) Invoking service asynchronously

(This message has been automatically imported from the retired mailing list)

Hi,

I have a service exposed through a plain http channel. Now, this service
relies on calling an external API which takes a long time.

I’d like to quickly acknowledge the reception of the API call to the
client, and then perform the external API call asynchronously.

My current solution (which I have no idea whether is good) is using two
services. The first one invokes the real implementation with
self.invoke_async.

Is this the right way to do it? Is there a way to expose a service in
an asynchronous way without relying on a second service?

Thanks for your help

On 16/03/15 18:03, Andrés Fernández wrote:

Is this the right way to do it? Is there a way to expose a service in
an asynchronous way without relying on a second service?

I would say this is a good approach if this is generic HTTP client.

After all, after you quickly confirm the reception the client is not
waiting for anything else within the same TCP/HTTP connection.

However, if this is a Python client using zato-client …

https://pypi.python.org/pypi/zato-client

… you can make it call your service using .invoke_async …

https://zato.io/docs/progguide/clients/python.html#invoke-async

That way the client will invoke the target service straightaway.

A nice idea would be to add an ‘Async’ checkbox to the GUI/API so that
HTTP channels could report the initial invocation’s status automatically
to any HTTP clients?

Hi Dariusz,

the python-client looks really nice although for now I’m trying not to use
it and deal with the HTTP APIs myself.

+1 for the Async checkbox, it would make this kind of things trivial. I’m
wondering if posing this question in the channel edit form would impede
also asking for a callback parameter.

On Mon, Mar 16, 2015 at 6:14 PM, Dariusz Suchojad dsuch@zato.io wrote:

On 16/03/15 18:03, Andr=C3=A9s Fern=C3=A1ndez wrote:

Is this the right way to do it? Is there a way to expose a service in
an asynchronous way without relying on a second service?

I would say this is a good approach if this is generic HTTP client.

After all, after you quickly confirm the reception the client is not
waiting for anything else within the same TCP/HTTP connection.

However, if this is a Python client using zato-client …

https://pypi.python.org/pypi/zato-client

… you can make it call your service using .invoke_async …

https://zato.io/docs/progguide/clients/python.html#invoke-async

That way the client will invoke the target service straightaway.

A nice idea would be to add an ‘Async’ checkbox to the GUI/API so that
HTTP channels could report the initial invocation’s status automatically
to any HTTP clients?


Dariusz Suchojad

https://zato.io
ESB, SOA, REST, APIs and Cloud Integrations in Python

I was referring to the API described here:

https://zato.io/docs/progguide/patterns/async-invoke.html#async-invoke-expl=
icit-callback

In which one can call invoke_async while passing a callback service. I was
thinking that if Zato exposes an async checkbox, for consistency sake one
would expect to be able to fill out an optional callback parameter.

I’m wondering if this makes sense, I’m still learning Zato’s basics.

On Mon, Mar 16, 2015 at 8:36 PM, Dariusz Suchojad dsuch@zato.io wrote:

On 16/03/15 20:34, Andr=C3=A9s Fern=C3=A1ndez wrote:

I’m wondering if posing this question in the channel edit form would
impede also asking for a callback parameter.

A callback parameter? Sounds interesting but I’m not sure exactly what
you mean by that? How would it work?


Dariusz Suchojad

https://zato.io
ESB, SOA, REST, APIs and Cloud Integrations in Python