7

我在我的 python 项目中使用 App Engine 模块。(https://developers.google.com/appengine/docs/python/modules/#Python_Background_threads

我还在 m 项目中收到电子邮件: https ://developers.google.com/appengine/docs/python/mail/receivingmail

我想将电子邮件定向到我的工作模块而不是默认模块。为此,我的 worker.yaml 具有以下设置

工人.yaml

    api_version: 1
    application: integrate
    module: worker
    version: 1-0-0
    runtime: python27
    threadsafe: true

    inbound_services:
    - mail

    builtins:
    - deferred: on

    handlers:

    - url: /admin/.+
      script: src.worker.main.app
      login: admin

    - url: /_ah/mail/.+
      script: src.worker.main.app
      login: admin

    - url: /.*
      script: src.worker.main.app

应用程序.yaml

    api_version: 1
    application: integrate
    version: 1-0-0
    runtime: python27
    threadsafe: true

    builtins:
    - deferred: on

    handlers:

    - url: /admin/.+
      script: src.default.main.app
      login: admin

    - url: /.*
      script: src.default.main.app

我什至尝试添加一个 dispatch.yaml

    application: integrate

    dispatch:
    - url: "*/_ah/mail/.+"
      module: worker

但无论我做什么,到达我的应用程序的电子邮件都由默认模块处理。知道我在这里缺少什么吗?我看到电子邮件进来了,但无论我做什么,它们都只会转到默认模块。

4

2 回答 2

4

入站服务只能在默认模块中使用,这是预期的行为。实际上,它在 devserver 本地为您工作的事实是一个错误。

于 2014-03-19T13:35:36.367 回答
-1

只是一些额外的答案信息,可以帮助处于类似情况的人。

我在 DevServer 日志中注意到:

“跳过 dispatch.yaml 规则,因为 /_ah/mail/[EMAIL_ADDRESS_FOR_APP] 不是可调度路径。”

然而,这无疑是由于本地配置。

无论如何,我现在使用 Tasks 的解决方法是:

  • 在默认模块中发送或直接处理 Inbound Mail
  • 提供一个创建任务的脚本处理程序,将相关的 MailMessage 数据作为有效负载
  • 在 queue.yaml 中设置 TaskQueue 以针对您希望处理有效负载数据的模块,例如“worker”模块
于 2014-08-09T12:23:23.840 回答