How to send a task to a different service in Cloud Task (using python37 runtime)

186 views
Skip to first unread message

Pardeep Aulakh

unread,
Nov 29, 2019, 5:58:56 PM11/29/19
to Google App Engine
Hi,

How can I send a task to a different service in Cloud Task. I tried with `app_engine_routing` value in AppEngineHttpRequest, but the task is still executing in the same service (which I was able to verify from logs).
I am using `google.cloud.tasks.CloudTasksClient` lib in Python 37 runtime environment in GAE.


Thanks in advance,

Pierre-Yves Blain

unread,
Dec 2, 2019, 1:37:40 PM12/2/19
to Google App Engine

There are 2 methods for explicitly defining a target service [1]: declaring in the task itself or routing all tasks in a queue. Setting AppEngineRouting in AppEngineHttpRequest is indeed the preferred method for routing specific tasks to other services.


A few points are worth noting which may affect why the routing is not behaving as you intend:

1- As noted here [2], the appengine.applications.get IAM permission is required to use AppEngineRouting.

2- As noted here [3], “appEngineRoutingOverride” has priority in that if this is set on a queue pointing to a specific service, all tasks in a queue will have their target set to that service even if the AppEngineRouting is set at the individual level.

3- Configuring routing can be done against App Engine queues only [4]


If you wish to set up routing at the queue level, please try using the gcloud command to see if this is successful:

gcloud tasks queues update [QUEUE_ID] \     --routing-override=service:[SERVICE],version:[VERSION]


[1] https://cloud.google.com/tasks/docs/configuring-queues#routing
[2] https://cloud.google.com/tasks/docs/reference/rest/v2/AppEngineRouting

[3] https://cloud.google.com/tasks/docs/reference/rest/v2/projects.locations.queues.tasks#AppEngineHttpRequest.FIELDS.app_engine_routing

[4] https://cloud.google.com/tasks/docs/configuring-queues#routing


Reply all
Reply to author
Forward
0 new messages