Michael Gradek
Michael Gradek

Reputation: 2738

Dispatch isn't routing internal queue requests properly

I have a process a user can launch which inserts a bunch of items into a queue. This queue sends a request to the worker's url /pipeline/foo and the handler takes it from there.

The handler that consumes items coming into /pipeline/foo is on a separate module module-pipeline.

The issue is that in production dispatch.yaml doesn't seem to dispatch the internal requests made by the queue to the right module. However, if I manually send a request to the URL (as a user inserting the URL in the browser), it seems to dispatch me to the right module...

dispatch.yaml

application: my-app

dispatch:
  - url: "*/pipeline/*"
    module: module-pipeline

load-queue.py

# does some things before...

for url in urls_to_load:
    task = taskqueue.Task(url='/pipeline/foo', params={'id': url.key.id()})
    queue.add(task)

This works fine on the dev_appserver however in production when the queue sends the request to pipeline/fooits processed by the default module (returning a 404 as it's not implemented there), whereas if I send the same request manually through my browser (GET request), it's processed by module-pipeline

Any ideas what's wrong?

Upvotes: 1

Views: 149

Answers (1)

pgiecek
pgiecek

Reputation: 8200

Try to use parameter target when defining the queue in queue.yaml instead of routing defined in dispatch.yaml.

Target parameter

A string naming a module/version, a frontend version, or a backend, on which to execute all of the tasks enqueued onto this queue.

The module (or frontend or backend) and version in which the handler runs is determined by:

  • The target or header keyword arguments in your call to the Task() constructor.
  • The target directive in the queue.yaml file.

Upvotes: 1

Related Questions