Akhil Reddy
Akhil Reddy

Reputation: 33

How to get the activation ID of the action invoked in OpenWhisk?

When we invoke an action through the CLI, we get the activation ID as the result. But when we generate the API for the action in Bluemix and try to invoke the API, I receive only the result of the action. How can we get the activation ID of the action after the invocation? Should we be able to get the response later by using the activation ID?

Upvotes: 0

Views: 1161

Answers (2)

Fergara
Fergara

Reputation: 947

If you are invoking from the CLI using the following, you should get back the activation ID and the result:

wsk action invoke --blocking the-action-name

You can get a list of activations ordered from the most recent to the oldest:

wsk activation list

There´s a very nice documentation with a bunch of details and using diff languages --> https://console.ng.bluemix.net/docs/openwhisk/openwhisk_actions.html#openwhisk_actions_polling

Upvotes: 1

user6062970
user6062970

Reputation: 831

An action, in its execution context has its activation id available: it's available in the environment variables as __OW_ACTIVATION_ID.

You can return this value in your response - if you're using a web action or API gateway and have the ability to send custom headers as a result you can use that as a mechanism to return the id. Or simply return the id itself.

Given an activation id, you can use it later with the activation API to retrieve the result.

It sounds like you want a non-blocking activation as opposed to request/response style. For that if you aren't using a webaction or API gateway, the default invoke mechanism is non blocking which return to you the activation id.

Here is a reference to the API https://github.com/apache/incubator-openwhisk/blob/master/docs/rest_api.md

Upvotes: 1

Related Questions